Datasets:
AI4M
/

text
stringlengths
0
3.34M
If $S$ is locally path-connected and $c$ is a component of $S$, then $c$ is locally path-connected.
[STATEMENT] lemma dickson_less_vI: assumes "d (pp_of_term v) \<le> m" and "d (pp_of_term u) \<le> m" and "v \<prec>\<^sub>t u" shows "dickson_less_v d m v u" [PROOF STATE] proof (prove) goal (1 subgoal): 1. dickson_less_v d m v u [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: d (pp_of_term v) \<le> m d (pp_of_term u) \<le> m v \<prec>\<^sub>t u goal (1 subgoal): 1. dickson_less_v d m v u [PROOF STEP] by (simp add: dickson_less_v_def)
Require Import Base. Require Import BaseProofs. Inductive 𝔳 : Type := | 𝔳hole : 𝔳 | 𝔳pair : 𝔳 -> 𝔳 -> 𝔳 | 𝔳inj : nat -> 𝔳 -> 𝔳 | 𝔳lambda : 𝔵 -> 𝔳 -> 𝔳 | 𝔳suspend : 𝔢 -> 𝔳 with 𝔫 : Type := | 𝔫hole : 𝔫 | 𝔫pair : 𝔢 -> 𝔢 -> 𝔫 | 𝔫inj : nat -> 𝔢 -> 𝔫 | 𝔫lambda : 𝔵 -> 𝔢 -> 𝔫 | 𝔫return : 𝔢 -> 𝔫 | 𝔫flor : 𝔳 -> 𝔫. Fixpoint 𝔳2𝔱 (v : 𝔳) := match v with | 𝔳hole => 𝔱hole | 𝔳pair v1 v2 => 𝔱pair (𝔳2𝔱 v1) (𝔳2𝔱 v2) | 𝔳inj z v1 => 𝔱inj z (𝔳2𝔱 v1) | 𝔳lambda x v1 => 𝔱lambda x (𝔳2𝔱 v1) | 𝔳suspend e => 𝔱suspend e end. Definition 𝔫2𝔢 (n : 𝔫) := match n with | 𝔫hole => 𝔢hole | 𝔫pair e1 e2 => 𝔢pair e1 e2 | 𝔫inj z e => 𝔢inj z e | 𝔫lambda x e => 𝔢lambda x e | 𝔫return e => 𝔢return e | 𝔫flor v => 𝔢flor (𝔳2𝔱 v) end. Fixpoint 𝔱subst (t : 𝔱) (x : 𝔵) (v : 𝔱) : 𝔱 := match t with | 𝔱id x' => (match var_eq x x' with true => v | false => t end) | 𝔱hole => t | 𝔱holecase t' => 𝔱holecase (𝔱subst t' x v) | 𝔱pair t1 t2 => 𝔱pair (𝔱subst t1 x v) (𝔱subst t2 x v) | 𝔱prj z t' => 𝔱prj z (𝔱subst t' x v) | 𝔱inj z t' => 𝔱inj z (𝔱subst t' x v) | 𝔱case t' x1 t1 x2 t2 => 𝔱case (𝔱subst t' x v) x1 (𝔱subst t1 x v) x2 (𝔱subst t2 x v) | 𝔱lambda x' t' => 𝔱lambda x' (𝔱subst t' x v) | 𝔱app t1 t2 => 𝔱app (𝔱subst t1 x v) (𝔱subst t2 x v) | 𝔱suspend e => t end. Fixpoint 𝔢subst (e : 𝔢) (x : 𝔵) (n : 𝔢) : 𝔢 := match e with | 𝔢id x' => (match var_eq x x' with true => n | false => e end) | 𝔢hole => e | 𝔢holecase e' => 𝔢holecase (𝔢subst e' x n) | 𝔢holelet e1 e2 => 𝔢holelet (𝔢subst e1 x n) (𝔢subst e2 x n) | 𝔢pair e1 e2 => 𝔢pair (𝔢subst e1 x n) (𝔢subst e2 x n) | 𝔢let x1 x2 e1 e2 => 𝔢let x1 x2 (𝔢subst e1 x n) (𝔢subst e2 x n) | 𝔢inj z e => 𝔢inj z (𝔢subst e x n) | 𝔢case e' x1 e1 x2 e2 => 𝔢case (𝔢subst e' x n) x1 (𝔢subst e1 x n) x2 (𝔢subst e2 x n) | 𝔢lambda x' e' => 𝔢lambda x' (𝔢subst e' x n) | 𝔢app e1 e2 => 𝔢app (𝔢subst e1 x n) (𝔢subst e2 x n) | 𝔢return e' => 𝔢return (𝔢subst e' x n) | 𝔢bind x' e1 e2 => 𝔢bind x' (𝔢subst e1 x n) (𝔢subst e2 x n) | 𝔢force t => e | 𝔢flor t => e | 𝔢florlet x' e1 e2 => 𝔢florlet x' (𝔢subst e1 x n) (𝔢subst e2 x n) end.
function varargout = kj_grid(varargin) % KJ_GRID Application M-file for kj_grid.fig % FIG = KJ_GRID launch kj_grid GUI. % KJ_GRID('callback_name', ...) invoke the named callback. % Last Modified by GUIDE v2.0 12-Jun-2002 11:51:21 if nargin == 1 % LAUNCH GUI fig = openfig(mfilename,'reuse'); % Use system color scheme for figure: set(fig,'Color',get(groot,'defaultUicontrolBackgroundColor')); % Generate a structure of handles to pass to callbacks, and store it. handles = guihandles(fig); guidata(fig, handles); if varargin{1} == 1 set(handles.lblSpacingDepth, 'String', 'Latitude spacing [deg]:'); set(handles.txtSpacingDepth, 'String', '0.1'); set(handles.lblSpacingHorizontal, 'String', 'Longitude spacing [deg]:'); set(handles.txtSpacingHorizontal, 'String', '0.1'); else set(handles.lblSpacingDepth, 'String', 'Depth spacing [km]:'); set(handles.txtSpacingDepth, 'String', '1'); set(handles.lblSpacingHorizontal, 'String', 'Horizontal spacing [km]:'); set(handles.txtSpacingHorizontal, 'String', '1'); end if get(handles.chkRandomNode, 'Value') == 1 set(handles.txtNumberCalculationNode, 'Enable', 'on'); set(handles.chkRandomArea, 'Enable', 'on'); if get(handles.chkRandomArea, 'Value') == 1 set(handles.txtNumberCalculationArea, 'Enable', 'on'); else set(handles.txtNumberCalculationArea, 'Enable', 'off'); end else set(handles.txtNumberCalculationNode, 'Enable', 'off'); set(handles.chkRandomArea, 'Enable', 'off'); set(handles.txtNumberCalculationArea, 'Enable', 'off'); end if get(handles.chkLearningPeriod, 'Value') == 1 set(handles.txtLearningPeriod, 'Enable', 'on'); else set(handles.txtLearningPeriod, 'Enable', 'off'); end if get(handles.chkForecastPeriod, 'Value') == 1 set(handles.txtForecastPeriod, 'Enable', 'on'); else set(handles.txtForecastPeriod, 'Enable', 'off'); end if get(handles.radNumber, 'Value') == 1 set(handles.txtNumber, 'Enable', 'on'); set(handles.radRadius, 'Value', [0]); set(handles.txtRadius, 'Enable', 'off'); else set(handles.txtNumber, 'Enable', 'off'); set(handles.radRadius, 'Value', [1]); set(handles.txtRadius, 'Enable', 'on'); end if get(handles.chkSaveParameter, 'Value') == 1 set(handles.btnSaveParameter, 'Enable', 'on'); else set(handles.btnSaveParameter, 'Enable', 'off'); end if get(handles.chkMinMag, 'Value') == 1 set(handles.txtMinMag, 'Enable', 'off'); else set(handles.txtMinMag, 'Enable', 'on'); end % Wait for callbacks to run and window to be dismissed: uiwait(fig); if nargout > 0 varargout{1} = fig; end elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK try [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard catch disp(lasterr); end end % -------------------------------------------------------------------- function varargout = radNumber_Callback(h, eventdata, handles, varargin) if get(handles.radNumber, 'Value') == 1 set(handles.txtNumber, 'Enable', 'on'); set(handles.radRadius, 'Value', [0]); set(handles.txtRadius, 'Enable', 'off'); set(handles.radRectangle, 'Value', [0]); set(handles.txtSizeRectHorizontal, 'Enable', 'off'); set(handles.txtSizeRectDepth, 'Enable', 'off'); else set(handles.txtNumber, 'Enable', 'off'); set(handles.radRadius, 'Value', [1]); set(handles.txtRadius, 'Enable', 'on'); end % -------------------------------------------------------------------- function varargout = radRadius_Callback(h, eventdata, handles, varargin) if get(handles.radRadius, 'Value') == 1 set(handles.txtRadius, 'Enable', 'on'); set(handles.radNumber, 'Value', [0]); set(handles.txtNumber, 'Enable', 'off'); set(handles.radRectangle, 'Value', [0]); set(handles.txtSizeRectHorizontal, 'Enable', 'off'); set(handles.txtSizeRectDepth, 'Enable', 'off'); else set(handles.txtRadius, 'Enable', 'off'); set(handles.radNumber, 'Value', [1]); set(handles.txtNumber, 'Enable', 'on'); end % -------------------------------------------------------------------- function varargout = radRectangle_Callback(h, eventdata, handles, varargin) if get(handles.radRectangle, 'Value') == 1 set(handles.txtSizeRectHorizontal, 'Enable', 'on'); set(handles.txtSizeRectDepth, 'Enable', 'on'); set(handles.radRadius, 'Value', [0]); set(handles.txtRadius, 'Enable', 'off'); set(handles.radNumber, 'Value', [0]); set(handles.txtNumber, 'Enable', 'off'); else set(handles.txtRadius, 'Enable', 'off'); set(handles.radNumber, 'Value', [1]); set(handles.txtNumber, 'Enable', 'on'); end % -------------------------------------------------------------------- function varargout = chkRandomNode_Callback(h, eventdata, handles, varargin) if get(handles.chkRandomNode, 'Value') == 1 set(handles.txtNumberCalculationNode, 'Enable', 'on'); set(handles.chkRandomArea, 'Enable', 'on'); if get(handles.chkRandomArea, 'Value') == 1 set(handles.txtNumberCalculationArea, 'Enable', 'on'); else set(handles.txtNumberCalculationArea, 'Enable', 'off'); end else set(handles.txtNumberCalculationNode, 'Enable', 'off'); set(handles.chkRandomArea, 'Enable', 'off'); set(handles.txtNumberCalculationArea, 'Enable', 'off'); end % -------------------------------------------------------------------- function varargout = chkRandomArea_Callback(h, eventdata, handles, varargin) if get(handles.chkRandomArea, 'Value') == 1 set(handles.txtNumberCalculationArea, 'Enable', 'on'); else set(handles.txtNumberCalculationArea, 'Enable', 'off'); end % -------------------------------------------------------------------- function varargout = chkLearningPeriod_Callback(h, eventdata, handles, varargin) if get(handles.chkLearningPeriod, 'Value') == 1 set(handles.txtLearningPeriod, 'Enable', 'on'); else set(handles.txtLearningPeriod, 'Enable', 'off'); end % -------------------------------------------------------------------- function varargout = chkForecastPeriod_Callback(h, eventdata, handles, varargin) if get(handles.chkForecastPeriod, 'Value') == 1 set(handles.txtForecastPeriod, 'Enable', 'on'); else set(handles.txtForecastPeriod, 'Enable', 'off'); end % -------------------------------------------------------------------- function varargout = chkSaveParameter_Callback(h, eventdata, handles, varargin) if get(handles.chkSaveParameter, 'Value') == 1 set(handles.btnSaveParameter, 'Enable', 'on'); else set(handles.btnSaveParameter, 'Enable', 'off'); end % -------------------------------------------------------------------- function varargout = chkMinMag_Callback(h, eventdata, handles, varargin) if get(handles.chkMinMag, 'Value') == 1 set(handles.txtMinMag, 'Enable', 'off'); else set(handles.txtMinMag, 'Enable', 'on'); end % -------------------------------------------------------------------- function varargout = btnSaveParameter_Callback(h, eventdata, handles, varargin) [newfile, newpath] = uiputfile('*.mat','Choose parameter file'); % Cancel pressed? if isequal(newfile, 0) || isequal(newpath, 0) return; end % Everything ok? newfile = [newpath newfile]; if length(newfile) > 1 set(handles.lblSaveParameter, 'String', newfile); end % -------------------------------------------------------------------- function varargout = btnCancel_Callback(h, eventdata, handles, varargin) handles.answer = 0; guidata(h, handles); uiresume(handles.figGrid); % -------------------------------------------------------------------- function varargout = btnOk_Callback(h, eventdata, handles, varargin) % Validation of inputs if get(handles.radNumber, 'Value') == 1 Tmp = str2double(get(handles.txtNumber, 'String')); if (isnan(Tmp) | (Tmp ~= round(Tmp)) | (Tmp <= 0)) errordlg('Number of events must be a positive integer value'); return; end end if get(handles.radRadius, 'Value') == 1 Tmp = str2double(get(handles.txtRadius, 'String')); if (isnan(Tmp) | (Tmp <= 0)) errordlg('Constant radius must be a positive float value'); return; end end Tmp = str2double(get(handles.txtMinimumNumber, 'String')); if (isnan(Tmp) | (Tmp ~= round(Tmp)) | (Tmp <= 0)) errordlg('Minimum number of events must be a positive integer value'); return; end Tmp = str2double(get(handles.txtSpacingHorizontal, 'String')); if (isnan(Tmp) | (Tmp <= 0)) errordlg('Horizontal spacing must be a positive float value'); return; end Tmp = str2double(get(handles.txtSpacingDepth, 'String')); if (isnan(Tmp) | (Tmp <= 0)) errordlg('Depth spacing must be a positive float value'); return; end if get(handles.chkLearningPeriod, 'Value') == 1 Tmp = str2double(get(handles.txtLearningPeriod, 'String')); if (isnan(Tmp) | (Tmp <= 0)) errordlg('Learning period must be a positive float value'); return; end end if get(handles.chkForecastPeriod, 'Value') == 1 Tmp = str2double(get(handles.txtForecastPeriod, 'String')); if (isnan(Tmp) | (Tmp <= 0)) errordlg('Forecasting period must be a positive float value'); return; end end Tmp = str2double(get(handles.txtSplitTime, 'String')); if (isnan(Tmp) | (Tmp <= 0)) errordlg('Splitting time must be a positive float value'); return; end if get(handles.chkRandomNode, 'Value') == 1 Tmp = str2double(get(handles.txtNumberCalculationNode, 'String')); if (isnan(Tmp) | (Tmp ~= round(Tmp)) | (Tmp <= 0)) errordlg('Number of calculations per node must be a positive integer value'); return; end if get(handles.chkRandomArea, 'Value') == 1 Tmp = str2double(get(handles.txtNumberCalculationArea, 'String')); if (isnan(Tmp) | (Tmp ~= round(Tmp)) | (Tmp <= 0)) errordlg('Number of calculations over area must be a positive integer value'); return; end end end if get(handles.chkSaveParameter, 'Value') == 1 Tmp = get(handles.lblSaveParameter, 'String'); if isempty(Tmp) errordlg('Please select a filename for storing the parameters.'); return; end end if get(handles.chkMinMag, 'Value') == 0 Tmp = str2double(get(handles.txtMinMag, 'String')); if (isnan(Tmp) | ((Tmp * 10) ~= round(Tmp * 10)) |(Tmp <= 0)) errordlg('Minimum magnitude must be a positive float value (precision 0.1)'); return; end end Tmp = str2double(get(handles.txtMaxMag, 'String')); if (isnan(Tmp) | ((Tmp * 10) ~= round(Tmp * 10)) |(Tmp <= 0)) errordlg('Maximum magnitude must be a positive float value (precision 0.1)'); return; end % OK, proceed handles.answer = 1; guidata(h, handles); uiresume(handles.figGrid);
```python import sympy as sym %matplotlib inline sym.init_printing() import matplotlib.pyplot as plt from sympy.plotting.plot import MatplotlibBackend def logx_plot(Hw, wrange, **kwargs): 'create plot with logarithmic x-axis' p = sym.plot(Hw, wrange, **kwargs) backend = MatplotlibBackend(p) backend.process_series() backend.ax[0].spines['left'].set_position(('axes', 0)) backend.ax[0].spines['bottom'].set_position(('axes', 0)) plt.xscale('log') plt.grid(which='both') return p def db(x): 'compute dB value' return 20 * sym.log(sym.Abs(x), 10) ``` # Combinación de Modelos Frecuenciales Es conveniente analizar sistemas elaborados como una representación de sistemas más sencillos. A continuación los principales tipos de combinación. ## Concatenación / Serie Cuando dos sistemas LTI $H_1$ y $H_2$ están interconectados de manera que la salida de $H_1$ es la entrada de $H_2$. Esta es la conexión en **Serie** o **Concatenación de sistemas**. Suponga que: - La respuesta impulsional de $H_1$ es $h_1(t)$. - La respuesta impulsional de $H_2$ es $h_2(t)$. - La concatenación se excita con una señal $x(t)$. La salida de $H_1$ es entonces $x(t)*h_1(t)$. La salida de la concatenación de sistemas es: \begin{equation} y(t) = x(t) * h_1(t) * h_2(t) \end{equation} En el dominio de Laplace, la convolución anterior se transforma en: \begin{equation} Y(s) = \underbrace{H_1(s) \cdot H_2(s)}_{H(s)} \cdot X(s) \end{equation} Así, los dos sistemas concatenados tienen una equivalencia $H(s) = H_1(s) \cdot H_2(s)$. Si se tienen $N$ sistemas conectados en serie, el modelo equivalente está dado por la multiplicación de las respectivas funciones de transferencia. \begin{equation} H(s) = \prod_{n=1}^{N} H_n(s) \end{equation} **Ejemplo** Al concatenar filtros de bajo orden se obtiene un filtro de orden más elevado. Suponga las siguientes funciones de transferencia para filtros de orden 2. \begin{equation} G(s) = \frac{1}{LC s^2 + RC s + 1} \end{equation} Si se concatenan $N$ filtros con acoples de impedancia, se obtiene: \begin{equation} H_N(s) = \left( \frac{1}{LC s^2 + RC s + 1} \right)^N \end{equation} A continuación los diagramas de Bode. Para valores $R$, $L$ y $C$. ```python s = sym.symbols('s', complex=True) w = sym.symbols('omega', real=True) R = 1 L = 0.5 C = 0.4 N = sym.symbols('N', integer=True) H0 = 1/(L*C*s**2 + R*C*s + 1) HN = H0**N HN ``` Ahora se definen valores para $s = \sigma + j \omega$. ```python H0w = H0.subs(s, sym.I * w) HNw = HN.subs(s, sym.I * w) plt.rcParams['figure.figsize'] = 6, 2 m1 = logx_plot(db(H0w), (w, 0.1, 100), xlabel='$\omega$', ylabel='$20 \log_{10} | H(j \omega) |$ in dB', line_color='b', show=False); m2 = logx_plot(db(HNw.subs(N, 2)), (w, 0.1, 100), xlabel='$\omega$', ylabel='$20 \log_{10} | H(j \omega) |$ in dB', line_color='r', show=False); m5 = logx_plot(db(HNw.subs(N, 5)), (w, 0.1, 100), xlabel='$\omega$', ylabel='$20 \log_{10} | H(j \omega) |$ in dB', line_color='g', show=False); f1 = logx_plot(sym.arg(H0w), (w, 0.1, 100), xlabel='$\omega$', ylabel=r'$\varphi(j \omega)$', line_color='b', show=False); f2 = logx_plot(sym.arg(HNw.subs(N, 2)), (w, 0.1, 100), xlabel='$\omega$', ylabel=r'$\varphi(j \omega)$', line_color='r', show=False); f5 = logx_plot(sym.arg(HNw.subs(N, 5)), (w, 0.1, 100), xlabel='$\omega$', ylabel=r'$\varphi(j \omega)$', line_color='g', show=False); m1.extend(m2) m1.extend(m5) f1.extend(f2) f1.extend(f5) ``` ```python backend = MatplotlibBackend(m1) backend.process_series() backend.ax[0].spines['left'].set_position(('axes', 0)) backend.ax[0].spines['bottom'].set_position(('axes', 0)) plt.xscale('log') plt.grid(which='both') backend = MatplotlibBackend(f1) backend.process_series() backend.ax[0].spines['left'].set_position(('axes', 0)) backend.ax[0].spines['bottom'].set_position(('axes', 0)) plt.xscale('log') plt.grid(which='both') ``` ## Paralelo Cuando dos sistemas LTI comparten la misma entrada y sus salidas se combinan, están conectados en paralelo. Cuando dos sistemas LTI $H_1$ y $H_2$ están interconectados de manera que tienen la misma entrada y sus salidas se combinan, esta es la conexión en **Serie** o **Concatenación de sistemas**. Suponga que: - La respuesta impulsional de $H_1$ es $h_1(t)$. - La respuesta impulsional de $H_2$ es $h_2(t)$. - La conexión paralela se excita con una señal $x(t)$. La salida de $H_1$ es entonces $x(t)*h_1(t)$. La salida de $H_2$ es entonces $x(t)*h_2(t)$. La salida de la conexión paralela es: \begin{equation} y(t) = h_1(t) * x(t) + h_2(t) * x(t) \end{equation} En el dominio de Laplace, la combinación anterior se transforma en: \begin{equation} Y(s) = \underbrace{\left( H_1(s) + H_2(s) \right)}_{H(s)} \cdot X(s) \end{equation} Así, los dos sistemas en paralelo tienen una equivalencia $H(s) = H_1(s) + H_2(s)$. Si se tienen $N$ sistemas conectados en paralelo, el modelo equivalente está dado por la suma de las respectivas funciones de transferencia. \begin{equation} H(s) = \sum_{n=1}^{N} H_n(s) \end{equation} ## Realimentación En algunos casos, parte de la señal de salida de $H_1$ es devuelta a su entrada a través de otro sistema $H_2$. Esta conexión es llamada **realimentación**. La salida $y(t)$ está dada por: \begin{equation} y(t) = (x(t) + y(t) * h_2(t)) * h_1(t) \end{equation} En el dominio de Laplace, la expresión se transforma en: \begin{equation} y(t) = (x(t) + y(t) * h_2(t)) * h_1(t) \end{equation} \begin{equation} Y(s) = (X(s) + Y(s) \cdot H_2(s)) \cdot H_1(s) \end{equation} \begin{equation} Y(s) = X(s) \cdot H_1(s) + Y(s) \cdot H_2(s) \cdot H_1(s) \end{equation} \begin{equation} Y(s) - Y(s) \cdot H_2(s) \cdot H_1(s) = X(s) \cdot H_1(s) \end{equation} \begin{equation} Y(s) \cdot (1 - H_2(s) \cdot H_1(s)) = X(s) \cdot H_1(s) \end{equation} \begin{equation} Y(s) = \frac{H_1(s)}{1 - H_1(s) \cdot H_2(s)} \cdot X(s) \end{equation} La equivalencia es \begin{equation} H(s) = \frac{H_1(s)}{1 - H_1(s) \cdot H_2(s)} \end{equation} Si la realimentación es negativa, la equivalencia es: \begin{equation} H(s) = \frac{H_1(s)}{1 + H_1(s) \cdot H_2(s)} \end{equation} ## Álgebra de bloques Cuando hay varios subsistemas interactuando entre sí, se modelan por separado y se identifican las conexiones entre ellos. Para encontrar equivalencias deben reducirse el sistema a una sola expresión con las siguientes normas. **Ejemplo** ## Ejercicio para entregar el 27 de noviembre Reducir el siguiente diagrama. Realice el ejercicio en papel y suba fotografías como evidencia. ## Próxima sesión Transformada Z
[STATEMENT] lemma Infinitesimal_less_SReal2: "y \<in> Infinitesimal \<Longrightarrow> \<forall>r \<in> Reals. 0 < r \<longrightarrow> y < r" for y :: hypreal [PROOF STATE] proof (prove) goal (1 subgoal): 1. y \<in> Infinitesimal \<Longrightarrow> \<forall>r\<in>\<real>. 0 < r \<longrightarrow> y < r [PROOF STEP] by (blast intro: Infinitesimal_less_SReal)
\documentclass[12pt]{article} \usepackage{fontspec} \usepackage{fullpage} \usepackage{hyperref} \hypersetup{bookmarks=true,colorlinks=true,linkcolor=red,citecolor=blue,filecolor=magenta,urlcolor=cyan} \usepackage{amsmath} \usepackage{amssymb} \usepackage{mathtools} \usepackage{unicode-math} \usepackage{tabu} \usepackage{longtable} \usepackage{booktabs} \usepackage{caption} \usepackage{graphics} \usepackage{enumitem} \usepackage{filecontents} \usepackage[backend=bibtex]{biblatex} \usepackage{url} \setmathfont{Latin Modern Math} \newcommand{\gt}{\ensuremath >} \newcommand{\lt}{\ensuremath <} \global\tabulinesep=1mm \newlist{symbDescription}{description}{1} \setlist[symbDescription]{noitemsep, topsep=0pt, parsep=0pt, partopsep=0pt} \bibliography{bibfile} \title{Software Requirements Specification for GlassBR} \author{Nikitha Krithnan and W. Spencer Smith} \begin{document} \maketitle \tableofcontents \newpage \section{Reference Material} \label{Sec:RefMat} This section records information for easy reference. \subsection{Table of Units} \label{Sec:ToU} The unit system used throughout is SI (Système International d'Unités). In addition to the basic units, several derived units are also used. For each unit, \hyperref[Table:ToU]{Tab: ToU} lists the symbol, a description and the SI name. \begin{longtable}{l l l} \toprule \textbf{Symbol} & \textbf{Description} & \textbf{SI Name} \\ \midrule \endhead kg & mass & kilogram \\ m & length & metre \\ N & force & newton \\ Pa & pressure & pascal \\ s & time & second \\ \bottomrule \caption{Table of Units} \label{Table:ToU} \end{longtable} \subsection{Table of Symbols} \label{Sec:ToS} The symbols used in this document are summarized in \hyperref[Table:ToS]{Tab: ToS} along with their units. The symbols are listed in alphabetical order. \begin{longtabu}{l X[l] l} \toprule \textbf{Symbol} & \textbf{Description} & \textbf{Units} \\ \midrule \endhead $a$ & Plate length (long dimension) & m \\ $AR$ & Aspect ratio & -- \\ ${AR_{\text{max}}}$ & Maximum aspect ratio & -- \\ $B$ & Risk of failure & -- \\ $b$ & Plate width (short dimension) & m \\ $capacity$ & Capacity or load resistance & Pa \\ ${d_{\text{max}}}$ & Maximum value for one of the dimensions of the glass plate & m \\ ${d_{\text{min}}}$ & Minimum value for one of the dimensions of the glass plate & m \\ $E$ & Modulus of elasticity of glass & Pa \\ $g$ & Glass type & -- \\ $GTF$ & Glass type factor & -- \\ $h$ & Minimum thickness & m \\ $interpY$ & InterpY & -- \\ $interpZ$ & InterpZ & -- \\ $is-safeLoad$ & Load resistance safety requirement & -- \\ $is-safeLR$ & 3 second load equivalent resistance safety requirement & -- \\ $is-safePb$ & Probability of glass breakage safety requirement & -- \\ $is-safeProb$ & Probability of failure safety requirement & -- \\ $J$ & Stress distribution factor (Function) & -- \\ ${J_{\text{tol}}}$ & Stress distribution factor (Function) based on Pbtol & -- \\ $k$ & Surface flaw parameter & $\frac{\text{m}^{12}}{\text{N}^{7}}$ \\ $LDF$ & Load duration factor & -- \\ $Load$ & Applied load (demand) or pressure & Pa \\ $LR$ & Load resistance & Pa \\ $LSF$ & Load share factor & -- \\ $m$ & Surface flaw parameter & $\frac{\text{m}^{12}}{\text{N}^{7}}$ \\ $NFL$ & Non-factored load & Pa \\ ${P_{\text{b}}}$ & Probability of breakage & -- \\ ${P_{\text{b}\text{tol}}}$ & Tolerable probability of breakage & -- \\ ${P_{\text{f}}}$ & Probability of failure & -- \\ ${P_{\text{f}\text{tol}}}$ & Tolerable probability of failure & -- \\ $q$ & Applied load (demand) & Pa \\ $\hat{q}$ & Dimensionless load & -- \\ ${\hat{q}_{\text{tol}}}$ & Tolerable load & -- \\ $SD$ & Stand off distance & m \\ ${SD_{\text{max}}}$ & Maximum stand off distance permissible for input & m \\ ${SD_{\text{min}}}$ & Minimum stand off distance permissible for input & m \\ ${SD_{\text{x}}}$ & stand off distance ($x$-component) & m \\ ${SD_{\text{y}}}$ & stand off distance ($y$-component) & m \\ ${SD_{\text{z}}}$ & stand off distance ($z$-component) & m \\ $t$ & Nominal thickness $t\in{}\{2.5,2.7,3.0,4.0,5.0,6.0,8.0,10.0,12.0,16.0,19.0,22.0\}$ & mm \\ ${t_{\text{d}}}$ & Duration of load & s \\ $TNT$ & TNT equivalent factor & -- \\ $w$ & Charge weight & kg \\ ${w_{\text{max}}}$ & Maximum permissible input charge weight & kg \\ ${w_{\text{min}}}$ & Minimum permissible input charge weight & kg \\ ${w_{TNT}}$ & Equivalent TNT charge mass & kg \\ \bottomrule \caption{Table of Symbols} \label{Table:ToS} \end{longtabu} \subsection{Abbreviations and Acronyms} \label{Sec:TAbbAcc} \begin{longtable}{l l} \toprule \textbf{Abbreviation} & \textbf{Full Form} \\ \midrule \endhead A & Assumption \\ AN & Annealed \\ AR & Aspect Ratio \\ DD & Data Definition \\ FT & Fully Tempered \\ GS & Goal Statement \\ GTF & Glass Type Factor \\ HS & Heat Strengthened \\ IG & Insulating Glass \\ IM & Instance Model \\ LC & Likely Change \\ LG & Laminated Glass \\ LR & Load Resistance \\ LSF & Load Share Factor \\ N/A & Not Applicable \\ NFL & Non-Factored Load \\ PS & Physical System Description \\ R & Requirement \\ SD & Stand Off Distance \\ SRS & Software Requirements Specification \\ TM & Theoretical Model \\ UC & Unlikely Change \\ Uncert. & Typical Uncertainty \\ \bottomrule \caption{Abbreviations and Acronyms} \label{Table:TAbbAcc} \end{longtable} \section{Introduction} \label{Sec:Intro} Software is helpful to efficiently and correctly predict the blast risk involved with the glass slab. The blast under consideration is any kind of man-made explosion. The software, herein called GlassBR, aims to predict the blast risk involved with the glass slab using an intuitive interface. The following section provides an overview of the Software Requirements Specification (SRS) for GlassBR. This section explains the purpose of this document, the scope of the requirements, the characteristics of the intended reader, and the organization of the document. \subsection{Purpose of Document} \label{Sec:DocPurpose} The main purpose of this document is to predict whether a given glass slab is likely to resist a specified blast. The goals and theoretical models used in the GlassBR code are provided, with an emphasis on explicitly identifying assumptions and unambiguous definitions. This document is intended to be used as a reference to provide all information necessary to understand and verify the analysis. The SRS is abstract because the contents say what problem is being solved, but not how to solve it. This document will be used as a starting point for subsequent development phases, including writing the design specification and the software verification and validation plan. The design document will show how the requirements are to be realized, including decisions on the numerical algorithms and programming environment. The verification and validation plan will show the steps that will be used to increase confidence in the software documentation and the implementation. Although the SRS fits in a series of documents that follow the so-called waterfall model, the actual development process is not constrained in any way. Even when the waterfall model is not followed, as Parnas and Clements point out \cite{parnasClements1986}, the most logical way to present the documentation is still to ``fake'' a rational design process. \subsection{Scope of Requirements} \label{Sec:ReqsScope} The scope of the requirements includes determining the safety of a glass slab under a blast loading following the ASTM standard (\cite{astm2009}). \subsection{Characteristics of Intended Reader} \label{Sec:ReaderChars} Reviewers of this documentation should have an understanding of second year calculus, structural mechanics, glass breakage, blast risk, computer applications in civil engineering, and applicable standards for constructions using glass from \cite{astm2009}, \cite{astm2012}, and \cite{astm2016} in \hyperref[Sec:References]{Section: References}. The users of GlassBR can have a lower level of expertise, as explained in \hyperref[Sec:UserChars]{Section: User Characteristics}. \subsection{Organization of Document} \label{Sec:DocOrg} The organization of this document follows the template for an SRS for scientific computing software proposed by \cite{koothoor2013} and \cite{smithLai2005}, with some aspects taken from Volere template 16 \cite{rbrtsn2012}. The presentation follows the standard pattern of presenting goals, theories, definitions, and assumptions. For readers that would like a more bottom up approach, they can start reading the data definitions in \hyperref[Sec:IMs]{Section: Instance Models} and trace back to find any additional information they require. The goal statements (\hyperref[Sec:GoalStmt]{Section: Goal Statements}) are refined to the theoretical models and the theoretical models (\hyperref[Sec:TMs]{Section: Theoretical Models}) to the instance models (\hyperref[Sec:IMs]{Section: Instance Models}). The data definitions are used to support the definitions of the different models. \section{Stakeholders} \label{Sec:Stakeholder} This section describes the stakeholders: the people who have an interest in the product. \subsection{The Client} \label{Sec:Client} The client for GlassBR is a company named Entuitive. It is developed by Dr. Manuel Campidelli. The client has the final say on acceptance of the product. \subsection{The Customer} \label{Sec:Customer} The customers are the end user of GlassBR. \section{General System Description} \label{Sec:GenSysDesc} This section provides general information about the system. It identifies the interfaces between the system and its environment, describes the user characteristics, and lists the system constraints. \subsection{System Context} \label{Sec:SysContext} \hyperref[Figure:sysCtxDiag]{Fig:sysCtxDiag} shows the system context. A circle represents an external entity outside the software, the user in this case. A rectangle represents the software system itself (GlassBR). Arrows are used to show the data flow between the system and its environment. \begin{figure} \begin{center} \includegraphics[width=\textwidth]{../../../datafiles/GlassBR/SystemContextFigure.png} \caption{System Context} \label{Figure:sysCtxDiag} \end{center} \end{figure} The interaction between the product and the user is through a user interface. The responsibilities of the user and the system are as follows: \begin{itemize} \item{User Responsibilities} \begin{itemize} \item{Provide the input data related to the glass slab and blast type, ensuring no errors in the data entry.} \item{Ensure that consistent units are used for input variables.} \item{Ensure required software assumptions (\hyperref[Sec:Assumps]{Section: Assumptions}) are appropriate for any particular problem input to the software.} \end{itemize} \item{GlassBR Responsibilities} \begin{itemize} \item{Detect data type mismatch, such as a string of characters input instead of a floating point number.} \item{Determine if the inputs satisfy the required physical and software constraints.} \item{Predict whether the glass slab is safe or not.} \end{itemize} \end{itemize} \subsection{User Characteristics} \label{Sec:UserChars} \begin{itemize} \item{The end user of GlassBR is expected to have completed at least the equivalent of the second year of an undergraduate degree in civil engineering or structural engineering.} \item{The end user is expected to have an understanding of theory behind glass breakage and blast risk.} \item{The end user is expected to have basic computer literacy to handle the software.} \end{itemize} \subsection{System Constraints} \label{Sec:SysConstraints} There are no system constraints. \section{Specific System Description} \label{Sec:SpecSystDesc} This section first presents the problem description, which gives a high-level view of the problem to be solved. This is followed by the solution characteristics specification, which presents the assumptions, theories, and definitions that are used. \subsection{Problem Description} \label{Sec:ProbDesc} A system is needed to efficiently and correctly predict whether a glass slab can withstand a blast under given conditions. \subsubsection{Terminology and Definitions} \label{Sec:TermDefs} This subsection provides a list of terms that are used in the subsequent sections and their meaning, with the purpose of reducing ambiguity and making it easier to correctly understand the requirements. All of the terms are extracted from \cite{astm2009}. \begin{enumerate} \item{Glass breakage - The fracture or breakage of any lite or ply in monolithic, laminated, or insulating glass.} \item{Lateral - Perpendicular to the glass surface.} \item{Lite - Pieces of glass that are cut, prepared, and used to create the window or door.} \item{Specifying authority - The design professional responsible for interpreting applicable regulations of authorities having jurisdiction and considering appropriate site specific factors to determine the appropriate values used to calculate the specified design load, and furnishing other information required to perform this practice.} \item{Blast resistant glazing - Glazing that provides protection against air blast pressure generated by explosions.} \item{Equivalent TNT charge mass - Mass of TNT placed on the ground in a hemisphere that represents the design explosive threat.} \item{Glass Type:} \begin{itemize} \item{Annealed (AN) - A flat, monolithic, glass lite which has uniform thickness where the residual surface stresses are almost zero, as defined in \cite{astm2016}.} \item{Fully tempered (FT) - A flat, monolithic, glass lite of uniform thickness that has been subjected to a special heat treatment process where the residual surface compression is not less than 69 MPa (10 000 psi) or the edge compression not less than 67 MPa (9700 psi), as defined in \cite{astm2012}.} \item{Heat strengthened (HS) - A flat, monolithic, glass lite of uniform thickness that has been subjected to a special heat treatment process where the residual surface compression is not less than 24 MPa (3500psi) or greater than 52 MPa (7500 psi), as defined in \cite{astm2012}.} \end{itemize} \item{Applied load (demand) or pressure - A uniformly distributed lateral pressure.} \begin{itemize} \item{Load resistance (LR) - The uniform lateral load that a glass construction can sustain based upon a given probability of breakage and load duration as defined in \cite[(pp. 1 and 53)]{astm2009}.} \item{Non-factored load (NFL) - Three second duration uniform load associated with a probability of breakage less than or equal to 8 lites per 1000 for monolithic AN glass.} \item{Glass weight load - The dead load component of the glass weight.} \item{Short duration load - Any load lasting 3 seconds or less.} \item{Specified design load - The magnitude in Pa (psf), type (for example, wind or snow) and duration of the load given by the specifying authority.} \item{Long duration load - Any load lasting approximately 30 days.} \end{itemize} \item{Stand off distance (SD) - The distance from the glazing surface to the centroid of a hemispherical high explosive charge. It is represented by the coordinates (${SD_{\text{x}}}$, ${SD_{\text{y}}}$, ${SD_{\text{z}}}$).} \item{Load share factor (LSF) - A multiplying factor derived from the load sharing between the double glazing, of equal or different thicknesses and types (including the layered behaviour of LG under long duration loads), in a sealed IG unit.} \item{Glass type factor (GTF) - A multiplying factor for adjusting the LR of different glass type, that is, AN, FT, or HS, in monolithic glass, LG (Laminated Glass), or IG (Insulating Glass) constructions.} \item{Aspect ratio (AR) - The ratio of the long dimension of the glass to the short dimension of the glass. For glass supported on four sides, the aspect ratio is always equal to or greater than 1.0. For glass supported on three sides, the ratio of the length of one of the supported edges perpendicular to the free edge, to the length of the free edge, is equal to or greater than 0.5.} \item{Probability of breakage (${P_{\text{b}}}$) - The fraction of glass lites or plies that would break at the first occurrence of a specified load and duration, typically expressed in lites per 1000 (\cite{astm2016}).} \end{enumerate} \subsubsection{Physical System Description} \label{Sec:PhysSyst} The physical system of GlassBR, as shown in \hyperref[Figure:physSystImage]{Fig:physSystImage}, includes the following elements: \begin{itemize} \item[PS1:]{The glass slab.} \item[PS2:]{The point of explosion. Where the bomb, or any kind of man-made explosion, is located. The stand off distance is the distance between the point of explosion and the glass.} \end{itemize} \begin{figure} \begin{center} \includegraphics[width=0.3\textwidth]{../../../datafiles/GlassBR/physicalsystimage.png} \caption{The physical system} \label{Figure:physSystImage} \end{center} \end{figure} \subsubsection{Goal Statements} \label{Sec:GoalStmt} Given the dimensions of the glass plane, the glass type, the characteristics of the explosion, and the tolerable probability of breakage, the goal statements are: \begin{itemize} \item[Predict-Glass-Withstands-Explosion:\phantomsection\label{willBreakGS}]{Analyze and predict whether the glass slab under consideration will be able to withstand the explosion of a certain degree which is calculated based on user input.} \end{itemize} \subsection{Solution Characteristics Specification} \label{Sec:SolCharSpec} The instance models that govern GlassBR are presented in \hyperref[Sec:IMs]{Section: Instance Models}. The information to understand the meaning of the instance models and their derivation is also presented, so that the instance models can be verified. \subsubsection{Assumptions} \label{Sec:Assumps} This section simplifies the original problem and helps in developing the theoretical models by filling in the missing information for the physical system. The assumptions refine the scope by providing more detail. \begin{itemize} \item[glassType:\phantomsection\label{assumpGT}]{The standard E1300-09a for calculation applies only to monolithic, laminated, or insulating glass constructions of rectangular shape with continuous lateral support along one, two, three, or four edges. This practice assumes that: (1) the supported glass edges for two, three and four-sided support conditions are simply supported and free to slip in plane; (2) glass supported on two sides acts as a simply supported beam; and (3) glass supported on one side acts as a cantilever.} \item[glassCondition:\phantomsection\label{assumpGC}]{Following \cite[(pg. 1)]{astm2009}, this practice does not apply to any form of wired, patterned, etched, sandblasted, drilled, notched, or grooved glass with surface and edge treatments that alter the glass strength. (RefBy: \hyperref[accAlteredGlass]{UC: Accommodate-Altered-Glass}.)} \item[explainScenario:\phantomsection\label{assumpES}]{This system only considers the external explosion scenario for its calculations. (RefBy: \hyperref[calcInternalBlastRisk]{LC: Calculate-Internal-Blask-Risk}.)} \item[standardValues:\phantomsection\label{assumpSV}]{The values provided in \hyperref[Sec:AuxConstants]{Section: Values of Auxiliary Constants} are assumed for the duration of load (${t_{\text{d}}}$), and the material properties of $m$, $k$, and $E$. (RefBy: \hyperref[varValsOfmkE]{LC: Variable-Values-of-m,k,E}, \hyperref[DD:sdfTol]{DD: sdfTol}, \hyperref[DD:nFL]{DD: nFL}, \hyperref[DD:loadDurFactor]{DD: loadDurFactor}, \hyperref[DD:dimlessLoad]{DD: dimlessLoad}, and \hyperref[assumpLDFC]{A: ldfConstant}.)} \item[glassLite:\phantomsection\label{assumpGL}]{Glass under consideration is assumed to be a single lite; hence, the value of LSF is equal to 1 for all calculations in GlassBR. (RefBy: \hyperref[accMoreThanSingleLite]{LC: Accomodate-More-than-Single-Lite}.)} \item[boundaryConditions:\phantomsection\label{assumpBC}]{Boundary conditions for the glass slab are assumed to be 4-sided support for calculations. (RefBy: \hyperref[accMoreBoundaryConditions]{LC: Accomodate-More-Boundary-Conditions}.)} \item[responseType:\phantomsection\label{assumpRT}]{The response type considered in GlassBR is flexural. (RefBy: \hyperref[considerMoreThanFlexGlass]{LC: Consider-More-than-Flexure-Glass}.)} \item[ldfConstant:\phantomsection\label{assumpLDFC}]{With reference to \hyperref[assumpSV]{A: standardValues}, the value of load duration factor ($LDF$) is a constant in GlassBR. (RefBy: \hyperref[varValsOfmkE]{LC: Variable-Values-of-m,k,E} and \hyperref[DD:loadDurFactor]{DD: loadDurFactor}.)} \end{itemize} \subsubsection{Theoretical Models} \label{Sec:TMs} This section focuses on the general equations and laws that GlassBR is based on. \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{TM:isSafeProb} \phantomsection \label{TM:isSafeProb} \\ \midrule \\ Label & Safety Probability \\ \midrule \\ Equation & \begin{displaymath} is-safeProb={P_{\text{f}}}\lt{}{P_{\text{f}\text{tol}}} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$is-safeProb$ is the probability of failure safety requirement (Unitless)} \item{${P_{\text{f}}}$ is the probability of failure (Unitless)} \item{${P_{\text{f}\text{tol}}}$ is the tolerable probability of failure (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & If $is-safeProb$, the structure is considered safe. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[checkGlassSafety]{FR: Check-Glass-Safety} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{TM:isSafeLoad} \phantomsection \label{TM:isSafeLoad} \\ \midrule \\ Label & Safety Load \\ \midrule \\ Equation & \begin{displaymath} is-safeLoad=capacity\gt{}Load \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$is-safeLoad$ is the load resistance safety requirement (Unitless)} \item{$capacity$ is the capacity or load resistance (Pa)} \item{$Load$ is the applied load (demand) or pressure (Pa)} \end{symbDescription} \\ \midrule \\ Notes & If $is-safeLoad$, the structure is considered safe. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[checkGlassSafety]{FR: Check-Glass-Safety} \\ \bottomrule \end{tabular} \end{minipage} \subsubsection{General Definitions} \label{Sec:GDs} There are no general definitions. \subsubsection{Data Definitions} \label{Sec:DDs} This section collects and defines all the data needed to build the instance models. \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:riskFun} \phantomsection \label{DD:riskFun} \\ \midrule \\ Label & Risk of failure \\ \midrule \\ Symbol & $B$ \\ \midrule \\ Units & Unitless \\ \midrule \\ Equation & \begin{displaymath} B=\frac{k}{\left(a b\right)^{m-1}} \left(E h^{2}\right)^{m} LDF e^{J} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$B$ is the risk of failure (Unitless)} \item{$k$ is the surface flaw parameter ($\frac{\text{m}^{12}}{\text{N}^{7}}$)} \item{$a$ is the plate length (long dimension) (m)} \item{$b$ is the plate width (short dimension) (m)} \item{$m$ is the surface flaw parameter ($\frac{\text{m}^{12}}{\text{N}^{7}}$)} \item{$E$ is the modulus of elasticity of glass (Pa)} \item{$h$ is the minimum thickness (m)} \item{$LDF$ is the load duration factor (Unitless)} \item{$J$ is the stress distribution factor (Function) (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & $a$ and $b$ are the dimensions of the plate, where ($a\geq{}b$). $h$ is defined in \hyperref[DD:minThick]{DD: minThick} and is based on the nominal thicknesses. $LDF$ is defined in \hyperref[DD:loadDurFactor]{DD: loadDurFactor}. $J$ is defined in \hyperref[DD:stressDistFac]{DD: stressDistFac}. \\ \midrule \\ Source & \cite{astm2009}, \cite[(Eqs. 4-5)]{beasonEtAl1998}, and \cite[(Eq. 14)]{campidelli} \\ \midrule \\ RefBy & \hyperref[DD:probOfBreak]{DD: probOfBreak} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:minThick} \phantomsection \label{DD:minThick} \\ \midrule \\ Label & Minimum thickness \\ \midrule \\ Symbol & $h$ \\ \midrule \\ Units & m \\ \midrule \\ Equation & \begin{displaymath} h=\frac{1}{1000} \begin{cases} 2.16, & t=2.5\\ 2.59, & t=2.7\\ 2.92, & t=3.0\\ 3.78, & t=4.0\\ 4.57, & t=5.0\\ 5.56, & t=6.0\\ 7.42, & t=8.0\\ 9.02, & t=10.0\\ 11.91, & t=12.0\\ 15.09, & t=16.0\\ 18.26, & t=19.0\\ 21.44, & t=22.0 \end{cases} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$h$ is the minimum thickness (m)} \item{$t$ is the nominal thickness $t\in{}\{2.5,2.7,3.0,4.0,5.0,6.0,8.0,10.0,12.0,16.0,19.0,22.0\}$ (mm)} \end{symbDescription} \\ \midrule \\ Notes & $t$ is a function that maps from the nominal thickness ($h$) to the minimum thickness. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:sdfTol]{DD: sdfTol}, \hyperref[DD:riskFun]{DD: riskFun}, \hyperref[DD:nFL]{DD: nFL}, and \hyperref[DD:dimlessLoad]{DD: dimlessLoad} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:loadDurFactor} \phantomsection \label{DD:loadDurFactor} \\ \midrule \\ Label & Load duration factor \\ \midrule \\ Symbol & $LDF$ \\ \midrule \\ Units & Unitless \\ \midrule \\ Equation & \begin{displaymath} LDF=\left(\frac{{t_{\text{d}}}}{60}\right)^{\frac{m}{16}} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$LDF$ is the load duration factor (Unitless)} \item{${t_{\text{d}}}$ is the duration of load (s)} \item{$m$ is the surface flaw parameter ($\frac{\text{m}^{12}}{\text{N}^{7}}$)} \end{symbDescription} \\ \midrule \\ Notes & ${t_{\text{d}}}$ and $m$ come from \hyperref[assumpSV]{A: standardValues}. $LDF$ is assumed to be constant (from \hyperref[assumpLDFC]{A: ldfConstant}). \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:sdfTol]{DD: sdfTol} and \hyperref[DD:riskFun]{DD: riskFun} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:stressDistFac} \phantomsection \label{DD:stressDistFac} \\ \midrule \\ Label & Stress distribution factor (Function) \\ \midrule \\ Symbol & $J$ \\ \midrule \\ Units & Unitless \\ \midrule \\ Equation & \begin{displaymath} J=interpZ\left(\text{``SDF.txt''},AR,\hat{q}\right) \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$J$ is the stress distribution factor (Function) (Unitless)} \item{$interpZ$ is the interpZ (Unitless)} \item{$AR$ is the aspect ratio (Unitless)} \item{$\hat{q}$ is the dimensionless load (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & $J$ is obtained by interpolating from data shown in \hyperref[Figure:dimlessloadVSaspect]{Fig:dimlessloadVSaspect}. $AR$ is defined in \hyperref[DD:aspectRatio]{DD: aspectRatio}. $\hat{q}$ is defined in \hyperref[DD:dimlessLoad]{DD: dimlessLoad}. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:riskFun]{DD: riskFun} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:nFL} \phantomsection \label{DD:nFL} \\ \midrule \\ Label & Non-factored load \\ \midrule \\ Symbol & $NFL$ \\ \midrule \\ Units & Pa \\ \midrule \\ Equation & \begin{displaymath} NFL=\frac{{\hat{q}_{\text{tol}}} E h^{4}}{\left(a b\right)^{2}} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$NFL$ is the non-factored load (Pa)} \item{${\hat{q}_{\text{tol}}}$ is the tolerable load (Unitless)} \item{$E$ is the modulus of elasticity of glass (Pa)} \item{$h$ is the minimum thickness (m)} \item{$a$ is the plate length (long dimension) (m)} \item{$b$ is the plate width (short dimension) (m)} \end{symbDescription} \\ \midrule \\ Notes & ${\hat{q}_{\text{tol}}}$ is defined in \hyperref[DD:tolLoad]{DD: tolLoad}. $E$ comes from \hyperref[assumpSV]{A: standardValues}. $h$ is defined in \hyperref[DD:minThick]{DD: minThick} and is based on the nominal thicknesses. $a$ and $b$ are the dimensions of the plate, where ($a\geq{}b$). \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:calofCapacity]{DD: calofCapacity} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:gTF} \phantomsection \label{DD:gTF} \\ \midrule \\ Label & Glass type factor \\ \midrule \\ Symbol & $GTF$ \\ \midrule \\ Units & Unitless \\ \midrule \\ Equation & \begin{displaymath} GTF=\begin{cases} 1, & g=\text{``AN''}\\ 4, & g=\text{``FT''}\\ 2, & g=\text{``HS''} \end{cases} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$GTF$ is the glass type factor (Unitless)} \item{$g$ is the glass type (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & AN is annealed glass. FT is fully tempered glass. HS is heat strengthened glass. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:calofCapacity]{DD: calofCapacity} and \hyperref[DD:dimlessLoad]{DD: dimlessLoad} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:dimlessLoad} \phantomsection \label{DD:dimlessLoad} \\ \midrule \\ Label & Dimensionless load \\ \midrule \\ Symbol & $\hat{q}$ \\ \midrule \\ Units & Unitless \\ \midrule \\ Equation & \begin{displaymath} \hat{q}=\frac{q \left(a b\right)^{2}}{E h^{4} GTF} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$\hat{q}$ is the dimensionless load (Unitless)} \item{$q$ is the applied load (demand) (Pa)} \item{$a$ is the plate length (long dimension) (m)} \item{$b$ is the plate width (short dimension) (m)} \item{$E$ is the modulus of elasticity of glass (Pa)} \item{$h$ is the minimum thickness (m)} \item{$GTF$ is the glass type factor (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & $q$ is the 3 second duration equivalent pressure, as given in \hyperref[DD:calofDemand]{DD: calofDemand}. $a$ and $b$ are the dimensions of the plate, where ($a\geq{}b$). $E$ comes from \hyperref[assumpSV]{A: standardValues}. $h$ is defined in \hyperref[DD:minThick]{DD: minThick} and is based on the nominal thicknesses. $GTF$ is defined in \hyperref[DD:gTF]{DD: gTF}. \\ \midrule \\ Source & \cite{astm2009} and \cite[(Eq. 7)]{campidelli} \\ \midrule \\ RefBy & \hyperref[DD:stressDistFac]{DD: stressDistFac} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:tolLoad} \phantomsection \label{DD:tolLoad} \\ \midrule \\ Label & Tolerable load \\ \midrule \\ Symbol & ${\hat{q}_{\text{tol}}}$ \\ \midrule \\ Units & Unitless \\ \midrule \\ Equation & \begin{displaymath} {\hat{q}_{\text{tol}}}=interpY\left(\text{``SDF.txt''},AR,{J_{\text{tol}}}\right) \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{${\hat{q}_{\text{tol}}}$ is the tolerable load (Unitless)} \item{$interpY$ is the interpY (Unitless)} \item{$AR$ is the aspect ratio (Unitless)} \item{${J_{\text{tol}}}$ is the stress distribution factor (Function) based on Pbtol (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & ${\hat{q}_{\text{tol}}}$ is obtained by interpolating from data shown in \hyperref[Figure:dimlessloadVSaspect]{Fig:dimlessloadVSaspect}. $AR$ is defined in \hyperref[DD:aspectRatio]{DD: aspectRatio}. ${J_{\text{tol}}}$ is defined in \hyperref[DD:sdfTol]{DD: sdfTol}. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:nFL]{DD: nFL} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:sdfTol} \phantomsection \label{DD:sdfTol} \\ \midrule \\ Label & Stress distribution factor (Function) based on Pbtol \\ \midrule \\ Symbol & ${J_{\text{tol}}}$ \\ \midrule \\ Units & Unitless \\ \midrule \\ Equation & \begin{displaymath} {J_{\text{tol}}}=\ln\left(\ln\left(\frac{1}{1-{P_{\text{b}\text{tol}}}}\right) \frac{\left(a b\right)^{m-1}}{k \left(E h^{2}\right)^{m} LDF}\right) \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{${J_{\text{tol}}}$ is the stress distribution factor (Function) based on Pbtol (Unitless)} \item{${P_{\text{b}\text{tol}}}$ is the tolerable probability of breakage (Unitless)} \item{$a$ is the plate length (long dimension) (m)} \item{$b$ is the plate width (short dimension) (m)} \item{$m$ is the surface flaw parameter ($\frac{\text{m}^{12}}{\text{N}^{7}}$)} \item{$k$ is the surface flaw parameter ($\frac{\text{m}^{12}}{\text{N}^{7}}$)} \item{$E$ is the modulus of elasticity of glass (Pa)} \item{$h$ is the minimum thickness (m)} \item{$LDF$ is the load duration factor (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & ${P_{\text{b}\text{tol}}}$ is entered by the user. $a$ and $b$ are the dimensions of the plate, where ($a\geq{}b$). $m$, $k$, and $E$ come from \hyperref[assumpSV]{A: standardValues}. $h$ is defined in \hyperref[DD:minThick]{DD: minThick} and is based on the nominal thicknesses. $LDF$ is defined in \hyperref[DD:loadDurFactor]{DD: loadDurFactor}. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:tolLoad]{DD: tolLoad} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:standOffDist} \phantomsection \label{DD:standOffDist} \\ \midrule \\ Label & Stand off distance \\ \midrule \\ Symbol & $SD$ \\ \midrule \\ Units & m \\ \midrule \\ Equation & \begin{displaymath} SD=\sqrt{{SD_{\text{x}}}^{2}+{SD_{\text{y}}}^{2}+{SD_{\text{z}}}^{2}} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$SD$ is the stand off distance (m)} \item{${SD_{\text{x}}}$ is the stand off distance ($x$-component) (m)} \item{${SD_{\text{y}}}$ is the stand off distance ($y$-component) (m)} \item{${SD_{\text{z}}}$ is the stand off distance ($z$-component) (m)} \end{symbDescription} \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:calofDemand]{DD: calofDemand} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:aspectRatio} \phantomsection \label{DD:aspectRatio} \\ \midrule \\ Label & Aspect ratio \\ \midrule \\ Symbol & $AR$ \\ \midrule \\ Units & Unitless \\ \midrule \\ Equation & \begin{displaymath} AR=\frac{a}{b} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$AR$ is the aspect ratio (Unitless)} \item{$a$ is the plate length (long dimension) (m)} \item{$b$ is the plate width (short dimension) (m)} \end{symbDescription} \\ \midrule \\ Notes & $a$ and $b$ are the dimensions of the plate, where ($a\geq{}b$). \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:tolLoad]{DD: tolLoad} and \hyperref[DD:stressDistFac]{DD: stressDistFac} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:eqTNTW} \phantomsection \label{DD:eqTNTW} \\ \midrule \\ Label & Equivalent TNT charge mass \\ \midrule \\ Symbol & ${w_{TNT}}$ \\ \midrule \\ Units & kg \\ \midrule \\ Equation & \begin{displaymath} {w_{TNT}}=w TNT \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{${w_{TNT}}$ is the equivalent TNT charge mass (kg)} \item{$w$ is the charge weight (kg)} \item{$TNT$ is the TNT equivalent factor (Unitless)} \end{symbDescription} \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[DD:calofDemand]{DD: calofDemand} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:probOfBreak} \phantomsection \label{DD:probOfBreak} \\ \midrule \\ Label & Probability of breakage \\ \midrule \\ Symbol & ${P_{\text{b}}}$ \\ \midrule \\ Units & Unitless \\ \midrule \\ Equation & \begin{displaymath} {P_{\text{b}}}=1-e^{-B} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{${P_{\text{b}}}$ is the probability of breakage (Unitless)} \item{$B$ is the risk of failure (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & $B$ is defined in \hyperref[DD:riskFun]{DD: riskFun}. \\ \midrule \\ Source & \cite{astm2009} and \cite{beasonEtAl1998} \\ \midrule \\ RefBy & \hyperref[IM:isSafePb]{IM: isSafePb} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:calofCapacity} \phantomsection \label{DD:calofCapacity} \\ \midrule \\ Label & Load resistance \\ \midrule \\ Symbol & $LR$ \\ \midrule \\ Units & Pa \\ \midrule \\ Equation & \begin{displaymath} LR=NFL GTF LSF \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$LR$ is the load resistance (Pa)} \item{$NFL$ is the non-factored load (Pa)} \item{$GTF$ is the glass type factor (Unitless)} \item{$LSF$ is the load share factor (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & $LR$ is also called capacity. $NFL$ is defined in \hyperref[DD:nFL]{DD: nFL}. $GTF$ is defined in \hyperref[DD:gTF]{DD: gTF}. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[IM:isSafeLR]{IM: isSafeLR} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{DD:calofDemand} \phantomsection \label{DD:calofDemand} \\ \midrule \\ Label & Applied load (demand) \\ \midrule \\ Symbol & $q$ \\ \midrule \\ Units & Pa \\ \midrule \\ Equation & \begin{displaymath} q=interpY\left(\text{``TSD.txt''},SD,{w_{TNT}}\right) \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$q$ is the applied load (demand) (Pa)} \item{$interpY$ is the interpY (Unitless)} \item{$SD$ is the stand off distance (m)} \item{${w_{TNT}}$ is the equivalent TNT charge mass (kg)} \end{symbDescription} \\ \midrule \\ Notes & $q$, or applied load (demand), is the 3 second duration equivalent pressure obtained from \hyperref[Figure:demandVSsod]{Fig:demandVSsod} by interpolation using stand off distance ($SD$) and ${w_{TNT}}$ as parameters. ${w_{TNT}}$ is defined in \hyperref[DD:eqTNTW]{DD: eqTNTW}. $SD$ is the stand off distance as defined in \hyperref[DD:standOffDist]{DD: standOffDist}. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[IM:isSafeLR]{IM: isSafeLR} and \hyperref[DD:dimlessLoad]{DD: dimlessLoad} \\ \bottomrule \end{tabular} \end{minipage} \subsubsection{Instance Models} \label{Sec:IMs} This section transforms the problem defined in \hyperref[Sec:ProbDesc]{Section: Problem Description} into one which is expressed in mathematical terms. It uses concrete symbols defined in \hyperref[Sec:DDs]{Section: Data Definitions} to replace the abstract symbols in the models identified in \hyperref[Sec:TMs]{Section: Theoretical Models} and \hyperref[Sec:GDs]{Section: General Definitions}. The goal \hyperref[willBreakGS]{GS: Predict-Glass-Withstands-Explosion} is met by \hyperref[IM:isSafePb]{IM: isSafePb}, \hyperref[IM:isSafeLR]{IM: isSafeLR}. \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{IM:isSafePb} \phantomsection \label{IM:isSafePb} \\ \midrule \\ Label & Safety Req-Pb \\ \midrule \\ Input & ${P_{\text{b}}}$, ${P_{\text{b}\text{tol}}}$ \\ \midrule \\ Output & $is-safePb$ \\ \midrule \\ Input Constraints & \begin{displaymath} {P_{\text{b}}}\gt{}0 \end{displaymath} \begin{displaymath} {P_{\text{b}\text{tol}}}\gt{}0 \end{displaymath} \\ \midrule \\ Output Constraints & \\ \midrule \\ Equation & \begin{displaymath} is-safePb={P_{\text{b}}}\lt{}{P_{\text{b}\text{tol}}} \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$is-safePb$ is the probability of glass breakage safety requirement (Unitless)} \item{${P_{\text{b}}}$ is the probability of breakage (Unitless)} \item{${P_{\text{b}\text{tol}}}$ is the tolerable probability of breakage (Unitless)} \end{symbDescription} \\ \midrule \\ Notes & If $is-safePb$, the glass is considered safe. $is-safePb$ and $is-safePb$ (from \hyperref[IM:isSafeLR]{IM: isSafeLR}) are either both True or both False. ${P_{\text{b}}}$ is defined in \hyperref[DD:probOfBreak]{DD: probOfBreak}. ${P_{\text{b}\text{tol}}}$ is entered by the user. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[IM:isSafeLR]{IM: isSafeLR} \\ \bottomrule \end{tabular} \end{minipage} \vspace{\baselineskip} \noindent \begin{minipage}{\textwidth} \begin{tabular}{>{\raggedright}p{0.13\textwidth}>{\raggedright\arraybackslash}p{0.82\textwidth}} \toprule \textbf{Refname} & \textbf{IM:isSafeLR} \phantomsection \label{IM:isSafeLR} \\ \midrule \\ Label & Safety Req-LR \\ \midrule \\ Input & $is-safeLR$, $LR$, $q$ \\ \midrule \\ Output & $is-safeLR$ \\ \midrule \\ Input Constraints & \begin{displaymath} LR\gt{}0 \end{displaymath} \begin{displaymath} q\gt{}0 \end{displaymath} \\ \midrule \\ Output Constraints & \\ \midrule \\ Equation & \begin{displaymath} is-safeLR=LR\gt{}q \end{displaymath} \\ \midrule \\ Description & \begin{symbDescription} \item{$is-safeLR$ is the 3 second load equivalent resistance safety requirement (Unitless)} \item{$LR$ is the load resistance (Pa)} \item{$q$ is the applied load (demand) (Pa)} \end{symbDescription} \\ \midrule \\ Notes & If $is-safeLR$, the glass is considered safe. $is-safePb$ (from \hyperref[IM:isSafePb]{IM: isSafePb}) and $is-safeLR$ are either both True or both False. $LR$ is defined in \hyperref[DD:calofCapacity]{DD: calofCapacity} and is also called capacity. $q$ is the 3 second duration equivalent pressure, as given in \hyperref[DD:calofDemand]{DD: calofDemand}. \\ \midrule \\ Source & \cite{astm2009} \\ \midrule \\ RefBy & \hyperref[IM:isSafePb]{IM: isSafePb} \\ \bottomrule \end{tabular} \end{minipage} \subsubsection{Data Constraints} \label{Sec:DataConstraints} \hyperref[Table:InDataConstraints]{Table:InDataConstraints} shows the data constraints on the input variables. The column for physical constraints gives the physical limitations on the range of values that can be taken by the variable. The uncertainty column provides an estimate of the confidence with which the physical quantities can be measured. This information would be part of the input if one were performing an uncertainty quantification exercise. The constraints are conservative, to give the user of the model the flexibility to experiment with unusual situations. The column of typical values is intended to provide a feel for a common scenario. \hyperref[Sec:AuxConstants]{Section: Values of Auxiliary Constants} gives the values of the specification parameters used in \hyperref[Table:InDataConstraints]{Table:InDataConstraints}. \begin{longtable}{l l l l l} \toprule \textbf{Var} & \textbf{Physical Constraints} & \textbf{Software Constraints} & \textbf{Typical Value} & \textbf{Uncert.} \\ \midrule \endhead $a$ & $a\gt{}0\land{}a\geq{}b$ & ${d_{\text{min}}}\leq{}a\leq{}{d_{\text{max}}}$ & $1.5$ m & 10$\%$ \\ $AR$ & $AR\geq{}1$ & $AR\leq{}{AR_{\text{max}}}$ & $1.5$ & 10$\%$ \\ $b$ & $0\lt{}b\leq{}a$ & ${d_{\text{min}}}\leq{}b\leq{}{d_{\text{max}}}$ & $1.2$ m & 10$\%$ \\ ${P_{\text{b}\text{tol}}}$ & $0\leq{}{P_{\text{b}\text{tol}}}\leq{}1$ & -- & $0.008$ & 0.1$\%$ \\ $SD$ & $SD\gt{}0$ & ${SD_{\text{min}}}\leq{}SD\leq{}{SD_{\text{max}}}$ & $45.0$ m & 10$\%$ \\ $TNT$ & $TNT\gt{}0$ & -- & $1.0$ & 10$\%$ \\ $w$ & $w\gt{}0$ & ${w_{\text{min}}}\leq{}w\leq{}{w_{\text{max}}}$ & $42.0$ kg & 10$\%$ \\ \bottomrule \caption{Input Data Constraints} \label{Table:InDataConstraints} \end{longtable} \subsubsection{Properties of a Correct Solution} \label{Sec:CorSolProps} \hyperref[Table:OutDataConstraints]{Table:OutDataConstraints} shows the data constraints on the output variables. The column for physical constraints gives the physical limitations on the range of values that can be taken by the variable. \begin{longtable}{l l} \toprule \textbf{Var} & \textbf{Physical Constraints} \\ \midrule \endhead ${P_{\text{b}}}$ & $0\leq{}{P_{\text{b}}}\leq{}1$ \\ \bottomrule \caption{Output Data Constraints} \label{Table:OutDataConstraints} \end{longtable} \section{Requirements} \label{Sec:Requirements} This section provides the functional requirements, the tasks and behaviours that the software is expected to complete, and the non-functional requirements, the qualities that the software is expected to exhibit. \subsection{Functional Requirements} \label{Sec:FRs} This section provides the functional requirements, the tasks and behaviours that the software is expected to complete. \begin{itemize} \item[Input-Values:\phantomsection\label{inputValues}]{Input the values from \hyperref[Table:ReqInputs]{Table:ReqInputs}, which define the glass dimensions, type of glass, tolerable probability of failure, and the characteristics of the blast.} \item[System-Set-Values-Following-Assumptions:\phantomsection\label{sysSetValsFollowingAssumps}]{The system shall set the known values as described in \hyperref[Table:ReqAssignments]{Table:ReqAssignments}.} \item[Check-Input-with-Data\_Constraints:\phantomsection\label{checkInputWithDataCons}]{The system shall check the entered input values to ensure that they do not exceed the data constraints mentioned in \hyperref[Sec:DataConstraints]{Section: Data Constraints}. If any of the input values are out of bounds, an error message is displayed and the calculations stop.} \item[Output-Values-and-Known-Values:\phantomsection\label{outputValsAndKnownValues}]{Output the input values from \hyperref[inputValues]{FR: Input-Values} and the known values from \hyperref[sysSetValsFollowingAssumps]{FR: System-Set-Values-Following-Assumptions}.} \item[Check-Glass-Safety:\phantomsection\label{checkGlassSafety}]{If $is-safePb\land{}is-safeLR$ (from \hyperref[TM:isSafeProb]{TM: isSafeProb} and \hyperref[TM:isSafeLoad]{TM: isSafeLoad}), output the message ``For the given input parameters, the glass is considered safe.'' If the condition is false, then output the message ``For the given input parameters, the glass is NOT considered safe.''} \item[Output-Values:\phantomsection\label{outputValues}]{Output the values from \hyperref[Table:ReqOutputs]{Table:ReqOutputs}.} \end{itemize} \begin{longtabu}{l X[l] l} \toprule \textbf{Symbol} & \textbf{Description} & \textbf{Units} \\ \midrule \endhead $a$ & Plate length (long dimension) & m \\ $b$ & Plate width (short dimension) & m \\ $g$ & Glass type & -- \\ ${P_{\text{b}\text{tol}}}$ & Tolerable probability of breakage & -- \\ ${SD_{\text{x}}}$ & stand off distance ($x$-component) & m \\ ${SD_{\text{y}}}$ & stand off distance ($y$-component) & m \\ ${SD_{\text{z}}}$ & stand off distance ($z$-component) & m \\ $t$ & Nominal thickness $t\in{}\{2.5,2.7,3.0,4.0,5.0,6.0,8.0,10.0,12.0,16.0,19.0,22.0\}$ & mm \\ $TNT$ & TNT equivalent factor & -- \\ $w$ & Charge weight & kg \\ \bottomrule \caption{Required Inputs following \hyperref[inputValues]{FR: Input-Values}} \label{Table:ReqInputs} \end{longtabu} \begin{longtable}{l l l l} \toprule \textbf{Symbol} & \textbf{Description} & \textbf{Source} & \textbf{Units} \\ \midrule \endhead $AR$ & Aspect ratio & \hyperref[DD:aspectRatio]{DD: aspectRatio} & -- \\ $E$ & Modulus of elasticity of glass & \hyperref[assumpSV]{A: standardValues} & Pa \\ $GTF$ & Glass type factor & \hyperref[DD:gTF]{DD: gTF} & -- \\ $h$ & Minimum thickness & \hyperref[DD:minThick]{DD: minThick} & m \\ $k$ & Surface flaw parameter & \hyperref[assumpSV]{A: standardValues} & $\frac{\text{m}^{12}}{\text{N}^{7}}$ \\ $LDF$ & Load duration factor & \hyperref[DD:loadDurFactor]{DD: loadDurFactor} & -- \\ $LSF$ & Load share factor & \hyperref[assumpGL]{A: glassLite} & -- \\ $m$ & Surface flaw parameter & \hyperref[assumpSV]{A: standardValues} & $\frac{\text{m}^{12}}{\text{N}^{7}}$ \\ $SD$ & Stand off distance & \hyperref[DD:standOffDist]{DD: standOffDist} & m \\ ${t_{\text{d}}}$ & Duration of load & \hyperref[assumpSV]{A: standardValues} & s \\ \bottomrule \caption{Required Assignments following \hyperref[sysSetValsFollowingAssumps]{FR: System-Set-Values-Following-Assumptions}} \label{Table:ReqAssignments} \end{longtable} \begin{longtabu}{l X[l] l l} \toprule \textbf{Symbol} & \textbf{Description} & \textbf{Source} & \textbf{Units} \\ \midrule \endhead $AR$ & Aspect ratio & \hyperref[DD:aspectRatio]{DD: aspectRatio} & -- \\ $B$ & Risk of failure & \hyperref[DD:riskFun]{DD: riskFun} & -- \\ $GTF$ & Glass type factor & \hyperref[DD:gTF]{DD: gTF} & -- \\ $h$ & Minimum thickness & \hyperref[DD:minThick]{DD: minThick} & m \\ $is-safeLR$ & Safety Req-LR & \hyperref[IM:isSafeLR]{IM: isSafeLR} & -- \\ $is-safePb$ & Safety Req-Pb & \hyperref[IM:isSafePb]{IM: isSafePb} & -- \\ $J$ & Stress distribution factor (Function) & \hyperref[DD:stressDistFac]{DD: stressDistFac} & -- \\ ${J_{\text{tol}}}$ & Stress distribution factor (Function) based on Pbtol & \hyperref[DD:sdfTol]{DD: sdfTol} & -- \\ $NFL$ & Non-factored load & \hyperref[DD:nFL]{DD: nFL} & Pa \\ $\hat{q}$ & Dimensionless load & \hyperref[DD:dimlessLoad]{DD: dimlessLoad} & -- \\ ${\hat{q}_{\text{tol}}}$ & Tolerable load & \hyperref[DD:tolLoad]{DD: tolLoad} & -- \\ \bottomrule \caption{Required Outputs following \hyperref[outputValues]{FR: Output-Values}} \label{Table:ReqOutputs} \end{longtabu} \subsection{Non-Functional Requirements} \label{Sec:NFRs} This section provides the non-functional requirements, the qualities that the software is expected to exhibit. \begin{itemize} \item[Correct:\phantomsection\label{correct}]{The outputs of the code have the properties described in \hyperref[Sec:CorSolProps]{Section: Properties of a Correct Solution}.} \item[Verifiable:\phantomsection\label{verifiable}]{The code is tested with complete verification and validation plan.} \item[Understandable:\phantomsection\label{understandable}]{The code is modularized with complete module guide and module interface specification.} \item[Reusable:\phantomsection\label{reusable}]{The code is modularized.} \item[Maintainable:\phantomsection\label{maintainable}]{The traceability between requirements, assumptions, theoretical models, general definitions, data definitions, instance models, likely changes, unlikely changes, and modules is completely recorded in traceability matrices in the SRS and module guide.} \item[Portable:\phantomsection\label{portable}]{The code is able to be run in different environments.} \end{itemize} \section{Likely Changes} \label{Sec:LCs} This section lists the likely changes to be made to the software. \begin{itemize} \item[Calculate-Internal-Blask-Risk:\phantomsection\label{calcInternalBlastRisk}]{\hyperref[assumpES]{A: explainScenario} - The system currently only calculates for external blast risk. In the future, calculations can be added for the internal blast risk.} \item[Variable-Values-of-m,k,E:\phantomsection\label{varValsOfmkE}]{\hyperref[assumpSV]{A: standardValues}, \hyperref[assumpLDFC]{A: ldfConstant} - Currently, the values for $m$, $k$, and $E$ are assumed to be the same for all glass. In the future, these values can be changed to variable inputs.} \item[Accomodate-More-than-Single-Lite:\phantomsection\label{accMoreThanSingleLite}]{\hyperref[assumpGL]{A: glassLite} - The software may be changed to accommodate more than a single lite.} \item[Accomodate-More-Boundary-Conditions:\phantomsection\label{accMoreBoundaryConditions}]{\hyperref[assumpBC]{A: boundaryConditions} - The software may be changed to accommodate more boundary conditions than 4-sided support.} \item[Consider-More-than-Flexure-Glass:\phantomsection\label{considerMoreThanFlexGlass}]{\hyperref[assumpRT]{A: responseType} - The software may be changed to consider more than just flexure of the glass.} \end{itemize} \section{Unlikely Changes} \label{Sec:UCs} This section lists the unlikely changes to be made to the software. \begin{itemize} \item[Predict-Withstanding-of-Certain-Degree:\phantomsection\label{predictWithstandOfCertDeg}]{The goal of the system is to predict whether the glass slab under consideration can withstand an explosion of a certain degree.} \item[Accommodate-Altered-Glass:\phantomsection\label{accAlteredGlass}]{\hyperref[assumpGC]{A: glassCondition} requires that the glass is not altered in any way. Therefore, this cannot be used on altered glass.} \end{itemize} \section{Traceability Matrices and Graphs} \label{Sec:TraceMatrices} The purpose of the traceability matrices is to provide easy references on what has to be additionally modified if a certain component is changed. Every time a component is changed, the items in the column of that component that are marked with an ``X'' should be modified as well. \hyperref[Table:TraceMatAvsAll]{Table:TraceMatAvsAll} shows the dependencies of data definitions, theoretical models, general definitions, instance models, requirements, likely changes, and unlikely changes on the assumptions. \hyperref[Table:TraceMatRefvsRef]{Table:TraceMatRefvsRef} shows the dependencies of data definitions, theoretical models, general definitions, and instance models with each other. \hyperref[Table:TraceMatAllvsR]{Table:TraceMatAllvsR} shows the dependencies of requirements, goal statements on the data definitions, theoretical models, general definitions, and instance models. \begin{longtable}{l l l l l l l l l} \toprule \textbf{} & \textbf{\hyperref[assumpGT]{A: glassType}} & \textbf{\hyperref[assumpGC]{A: glassCondition}} & \textbf{\hyperref[assumpES]{A: explainScenario}} & \textbf{\hyperref[assumpSV]{A: standardValues}} & \textbf{\hyperref[assumpGL]{A: glassLite}} & \textbf{\hyperref[assumpBC]{A: boundaryConditions}} & \textbf{\hyperref[assumpRT]{A: responseType}} & \textbf{\hyperref[assumpLDFC]{A: ldfConstant}} \\ \midrule \endhead \hyperref[DD:riskFun]{DD: riskFun} & & & & & & & & \\ \hyperref[DD:minThick]{DD: minThick} & & & & & & & & \\ \hyperref[DD:loadDurFactor]{DD: loadDurFactor} & & & & X & & & & X \\ \hyperref[DD:stressDistFac]{DD: stressDistFac} & & & & & & & & \\ \hyperref[DD:nFL]{DD: nFL} & & & & X & & & & \\ \hyperref[DD:gTF]{DD: gTF} & & & & & & & & \\ \hyperref[DD:dimlessLoad]{DD: dimlessLoad} & & & & X & & & & \\ \hyperref[DD:tolLoad]{DD: tolLoad} & & & & & & & & \\ \hyperref[DD:sdfTol]{DD: sdfTol} & & & & X & & & & \\ \hyperref[DD:standOffDist]{DD: standOffDist} & & & & & & & & \\ \hyperref[DD:aspectRatio]{DD: aspectRatio} & & & & & & & & \\ \hyperref[DD:eqTNTW]{DD: eqTNTW} & & & & & & & & \\ \hyperref[DD:probOfBreak]{DD: probOfBreak} & & & & & & & & \\ \hyperref[DD:calofCapacity]{DD: calofCapacity} & & & & & & & & \\ \hyperref[DD:calofDemand]{DD: calofDemand} & & & & & & & & \\ \hyperref[TM:isSafeProb]{TM: isSafeProb} & & & & & & & & \\ \hyperref[TM:isSafeLoad]{TM: isSafeLoad} & & & & & & & & \\ \hyperref[IM:isSafePb]{IM: isSafePb} & & & & & & & & \\ \hyperref[IM:isSafeLR]{IM: isSafeLR} & & & & & & & & \\ \hyperref[inputValues]{FR: Input-Values} & & & & & & & & \\ \hyperref[sysSetValsFollowingAssumps]{FR: System-Set-Values-Following-Assumptions} & & & & & & & & \\ \hyperref[checkInputWithDataCons]{FR: Check-Input-with-Data\_Constraints} & & & & & & & & \\ \hyperref[outputValsAndKnownValues]{FR: Output-Values-and-Known-Values} & & & & & & & & \\ \hyperref[checkGlassSafety]{FR: Check-Glass-Safety} & & & & & & & & \\ \hyperref[outputValues]{FR: Output-Values} & & & & & & & & \\ \hyperref[correct]{NFR: Correct} & & & & & & & & \\ \hyperref[verifiable]{NFR: Verifiable} & & & & & & & & \\ \hyperref[understandable]{NFR: Understandable} & & & & & & & & \\ \hyperref[reusable]{NFR: Reusable} & & & & & & & & \\ \hyperref[maintainable]{NFR: Maintainable} & & & & & & & & \\ \hyperref[portable]{NFR: Portable} & & & & & & & & \\ \hyperref[calcInternalBlastRisk]{LC: Calculate-Internal-Blask-Risk} & & & X & & & & & \\ \hyperref[varValsOfmkE]{LC: Variable-Values-of-m,k,E} & & & & X & & & & X \\ \hyperref[accMoreThanSingleLite]{LC: Accomodate-More-than-Single-Lite} & & & & & X & & & \\ \hyperref[accMoreBoundaryConditions]{LC: Accomodate-More-Boundary-Conditions} & & & & & & X & & \\ \hyperref[considerMoreThanFlexGlass]{LC: Consider-More-than-Flexure-Glass} & & & & & & & X & \\ \hyperref[predictWithstandOfCertDeg]{UC: Predict-Withstanding-of-Certain-Degree} & & & & & & & & \\ \hyperref[accAlteredGlass]{UC: Accommodate-Altered-Glass} & & X & & & & & & \\ \bottomrule \caption{Traceability Matrix Showing the Connections Between Assumptions and Other Items} \label{Table:TraceMatAvsAll} \end{longtable} \begin{longtable}{l l l l l l l l l l l l l l l l l l l l} \toprule \textbf{} & \textbf{\hyperref[DD:riskFun]{DD: riskFun}} & \textbf{\hyperref[DD:minThick]{DD: minThick}} & \textbf{\hyperref[DD:loadDurFactor]{DD: loadDurFactor}} & \textbf{\hyperref[DD:stressDistFac]{DD: stressDistFac}} & \textbf{\hyperref[DD:nFL]{DD: nFL}} & \textbf{\hyperref[DD:gTF]{DD: gTF}} & \textbf{\hyperref[DD:dimlessLoad]{DD: dimlessLoad}} & \textbf{\hyperref[DD:tolLoad]{DD: tolLoad}} & \textbf{\hyperref[DD:sdfTol]{DD: sdfTol}} & \textbf{\hyperref[DD:standOffDist]{DD: standOffDist}} & \textbf{\hyperref[DD:aspectRatio]{DD: aspectRatio}} & \textbf{\hyperref[DD:eqTNTW]{DD: eqTNTW}} & \textbf{\hyperref[DD:probOfBreak]{DD: probOfBreak}} & \textbf{\hyperref[DD:calofCapacity]{DD: calofCapacity}} & \textbf{\hyperref[DD:calofDemand]{DD: calofDemand}} & \textbf{\hyperref[TM:isSafeProb]{TM: isSafeProb}} & \textbf{\hyperref[TM:isSafeLoad]{TM: isSafeLoad}} & \textbf{\hyperref[IM:isSafePb]{IM: isSafePb}} & \textbf{\hyperref[IM:isSafeLR]{IM: isSafeLR}} \\ \midrule \endhead \hyperref[DD:riskFun]{DD: riskFun} & & X & X & X & & & & & & & & & & & & & & & \\ \hyperref[DD:minThick]{DD: minThick} & & & & & & & & & & & & & & & & & & & \\ \hyperref[DD:loadDurFactor]{DD: loadDurFactor} & & & & & & & & & & & & & & & & & & & \\ \hyperref[DD:stressDistFac]{DD: stressDistFac} & & & & & & & X & & & & X & & & & & & & & \\ \hyperref[DD:nFL]{DD: nFL} & & X & & & & & & X & & & & & & & & & & & \\ \hyperref[DD:gTF]{DD: gTF} & & & & & & & & & & & & & & & & & & & \\ \hyperref[DD:dimlessLoad]{DD: dimlessLoad} & & X & & & & X & & & & & & & & & X & & & & \\ \hyperref[DD:tolLoad]{DD: tolLoad} & & & & & & & & & X & & X & & & & & & & & \\ \hyperref[DD:sdfTol]{DD: sdfTol} & & X & X & & & & & & & & & & & & & & & & \\ \hyperref[DD:standOffDist]{DD: standOffDist} & & & & & & & & & & & & & & & & & & & \\ \hyperref[DD:aspectRatio]{DD: aspectRatio} & & & & & & & & & & & & & & & & & & & \\ \hyperref[DD:eqTNTW]{DD: eqTNTW} & & & & & & & & & & & & & & & & & & & \\ \hyperref[DD:probOfBreak]{DD: probOfBreak} & X & & & & & & & & & & & & & & & & & & \\ \hyperref[DD:calofCapacity]{DD: calofCapacity} & & & & & X & X & & & & & & & & & & & & & \\ \hyperref[DD:calofDemand]{DD: calofDemand} & & & & & & & & & & X & & X & & & & & & & \\ \hyperref[TM:isSafeProb]{TM: isSafeProb} & & & & & & & & & & & & & & & & & & & \\ \hyperref[TM:isSafeLoad]{TM: isSafeLoad} & & & & & & & & & & & & & & & & & & & \\ \hyperref[IM:isSafePb]{IM: isSafePb} & & & & & & & & & & & & & X & & & & & & X \\ \hyperref[IM:isSafeLR]{IM: isSafeLR} & & & & & & & & & & & & & & X & X & & & X & \\ \bottomrule \caption{Traceability Matrix Showing the Connections Between Items and Other Sections} \label{Table:TraceMatRefvsRef} \end{longtable} \begin{longtable}{l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l l} \toprule \textbf{} & \textbf{\hyperref[DD:riskFun]{DD: riskFun}} & \textbf{\hyperref[DD:minThick]{DD: minThick}} & \textbf{\hyperref[DD:loadDurFactor]{DD: loadDurFactor}} & \textbf{\hyperref[DD:stressDistFac]{DD: stressDistFac}} & \textbf{\hyperref[DD:nFL]{DD: nFL}} & \textbf{\hyperref[DD:gTF]{DD: gTF}} & \textbf{\hyperref[DD:dimlessLoad]{DD: dimlessLoad}} & \textbf{\hyperref[DD:tolLoad]{DD: tolLoad}} & \textbf{\hyperref[DD:sdfTol]{DD: sdfTol}} & \textbf{\hyperref[DD:standOffDist]{DD: standOffDist}} & \textbf{\hyperref[DD:aspectRatio]{DD: aspectRatio}} & \textbf{\hyperref[DD:eqTNTW]{DD: eqTNTW}} & \textbf{\hyperref[DD:probOfBreak]{DD: probOfBreak}} & \textbf{\hyperref[DD:calofCapacity]{DD: calofCapacity}} & \textbf{\hyperref[DD:calofDemand]{DD: calofDemand}} & \textbf{\hyperref[TM:isSafeProb]{TM: isSafeProb}} & \textbf{\hyperref[TM:isSafeLoad]{TM: isSafeLoad}} & \textbf{\hyperref[IM:isSafePb]{IM: isSafePb}} & \textbf{\hyperref[IM:isSafeLR]{IM: isSafeLR}} & \textbf{\hyperref[inputValues]{FR: Input-Values}} & \textbf{\hyperref[sysSetValsFollowingAssumps]{FR: System-Set-Values-Following-Assumptions}} & \textbf{\hyperref[checkInputWithDataCons]{FR: Check-Input-with-Data\_Constraints}} & \textbf{\hyperref[outputValsAndKnownValues]{FR: Output-Values-and-Known-Values}} & \textbf{\hyperref[checkGlassSafety]{FR: Check-Glass-Safety}} & \textbf{\hyperref[outputValues]{FR: Output-Values}} & \textbf{\hyperref[correct]{NFR: Correct}} & \textbf{\hyperref[verifiable]{NFR: Verifiable}} & \textbf{\hyperref[understandable]{NFR: Understandable}} & \textbf{\hyperref[reusable]{NFR: Reusable}} & \textbf{\hyperref[maintainable]{NFR: Maintainable}} & \textbf{\hyperref[portable]{NFR: Portable}} \\ \midrule \endhead \hyperref[willBreakGS]{GS: Predict-Glass-Withstands-Explosion} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[inputValues]{FR: Input-Values} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[sysSetValsFollowingAssumps]{FR: System-Set-Values-Following-Assumptions} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[checkInputWithDataCons]{FR: Check-Input-with-Data\_Constraints} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[outputValsAndKnownValues]{FR: Output-Values-and-Known-Values} & & & & & & & & & & & & & & & & & & & & X & X & & & & & & & & & & \\ \hyperref[checkGlassSafety]{FR: Check-Glass-Safety} & & & & & & & & & & & & & & & & X & X & & & & & & & & & & & & & & \\ \hyperref[outputValues]{FR: Output-Values} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[correct]{NFR: Correct} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[verifiable]{NFR: Verifiable} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[understandable]{NFR: Understandable} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[reusable]{NFR: Reusable} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[maintainable]{NFR: Maintainable} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \hyperref[portable]{NFR: Portable} & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\ \bottomrule \caption{Traceability Matrix Showing the Connections Between Requirements, Goal Statements and Other Items} \label{Table:TraceMatAllvsR} \end{longtable} \section{Values of Auxiliary Constants} \label{Sec:AuxConstants} This section contains the standard values that are used for calculations in GlassBR. \begin{longtabu}{l X[l] l l} \toprule \textbf{Symbol} & \textbf{Description} & \textbf{Value} & \textbf{Unit} \\ \midrule \endhead ${AR_{\text{max}}}$ & maximum aspect ratio & $5.0$ & -- \\ ${d_{\text{max}}}$ & maximum value for one of the dimensions of the glass plate & $5.0$ & m \\ ${d_{\text{min}}}$ & minimum value for one of the dimensions of the glass plate & $0.1$ & m \\ $E$ & modulus of elasticity of glass & $71.7\cdot{}10^{9}$ & Pa \\ $k$ & surface flaw parameter & $28.6\cdot{}10^{-54}$ & $\frac{\text{m}^{12}}{\text{N}^{7}}$ \\ $LSF$ & load share factor & $1$ & -- \\ $m$ & surface flaw parameter & $7.0$ & $\frac{\text{m}^{12}}{\text{N}^{7}}$ \\ ${SD_{\text{max}}}$ & maximum stand off distance permissible for input & $130.0$ & m \\ ${SD_{\text{min}}}$ & minimum stand off distance permissible for input & $6.0$ & m \\ ${t_{\text{d}}}$ & duration of load & $3.0$ & s \\ ${w_{\text{max}}}$ & maximum permissible input charge weight & $910.0$ & kg \\ ${w_{\text{min}}}$ & minimum permissible input charge weight & $4.5$ & kg \\ \bottomrule \caption{Auxiliary Constants} \label{Table:TAuxConsts} \end{longtabu} \section{References} \label{Sec:References} \begin{filecontents*}{bibfile.bib} @misc{astm2009, author={ASTM}, title={Standard Practice for Determining Load Resistance of Glass in Buildings}, publisher={ASTM International}, booktitle={Standard E1300-09a}, year={2009}, howpublished={\url{https://www.astm.org}}} @misc{astm2012, author={ASTM}, title={Standard Specification for Heat-Strengthened and Fully Tempered Flat Glass}, publisher={ASTM International}, address={West Conshohocken, PA}, year={2012}, howpublished={\url{https://doi.org/10.1520/C1048-12E01}}} @misc{astm2016, author={ASTM}, title={Standard specification for Flat Glass}, publisher={ASTM International}, address={West Conshohocken, PA}, year={2016}, howpublished={\url{https://doi.org/10.1520/C1036-16}}} @misc{beasonEtAl1998, author={Beason, W. Lynn and Kohutek, Terry L. and Bracci, Joseph M.}, title={Basis for ASTME E 1300 Annealed Glass Thickness Selection Charts}, booktitle={ASCE Library}, month=feb, year={1998}, howpublished={\url{https://doi.org/10.1061/(ASCE)0733-9445(1998)124:2(215)}}} @booklet{campidelli, title={Glass-BR Software for the design and risk assessment of glass facades subjected to blast loading}, author={Campidelli, Manuel}} @mastersthesis{koothoor2013, author={Koothoor, Nirmitha}, title={A document drive approach to certifying scientific computing software}, school={McMaster University}, year={2013}, address={Hamilton, ON, Canada}} @article{parnasClements1986, author={Parnas, David L. and Clements, P. C.}, title={A rational design process: How and why to fake it}, journal={IEEE Transactions on Software Engineering}, year={1986}, month=feb, volume={12}, number={2}, pages={251--257}, address={Washington, USA}} @misc{rbrtsn2012, author={Robertson, James and Robertson, Suzanne}, title={Volere requirements specification template edition 16}, howpublished={\url{https://pdfs.semanticscholar.org/cf57/27a59801086cbd3d14e587e09880561dbe22.pdf}}, year={2012}} @inproceedings{smithLai2005, author={Smith, W. Spencer and Lai, Lei}, title={A new requirements template for scientific computing}, booktitle={Proceedings of the First International Workshop on Situational Requirements Engineering Processes - Methods, Techniques and Tools to Support Situation-Specific Requirements Engineering Processes, SREP'05}, year={2005}, editor={Agerfalk, PJ and Kraiem, N. and Ralyte, J.}, address={Paris, France}, pages={107--121}, note={In conjunction with 13th IEEE International Requirements Engineering Conference,}} \end{filecontents*} \nocite{*} \bibstyle{ieeetr} \printbibliography[heading=none] \section{Appendix} \label{Sec:Appendix} This appendix holds the graphs (\hyperref[Figure:demandVSsod]{Fig:demandVSsod} and \hyperref[Figure:dimlessloadVSaspect]{Fig:dimlessloadVSaspect}) used for interpolating values needed in the models. \begin{figure} \begin{center} \includegraphics[width=\textwidth]{../../../datafiles/GlassBR/ASTM_F2248-09.png} \caption{3 second duration equivalent pressure ($q$) versus Stand off distance (SD) versus Charge weight ($w$)} \label{Figure:demandVSsod} \end{center} \end{figure} \begin{figure} \begin{center} \includegraphics[width=\textwidth]{../../../datafiles/GlassBR/ASTM_F2248-09_BeasonEtAl.png} \caption{Non dimensional lateral applied load (demand) or pressure ($\hat{q}$) versus Aspect Ratio (AR) versus Stress distribution factor (Function) ($J$)} \label{Figure:dimlessloadVSaspect} \end{center} \end{figure} \end{document}
"""Module to handle compatibility with dependencies like Astropy.""" from __future__ import absolute_import, division, print_function import astropy from astropy.utils.introspection import minversion __all__ = ['ASTROPY_LT_1_3'] ASTROPY_LT_1_3 = not minversion(astropy, '1.3')
module Peano where open import IPL data ℕ : Set where zero : ℕ -- Axiom 2.1. 0 is a natural number _++ : ℕ → ℕ -- Axiom 2.2. If n is a natural number, then n++ is also a natural number data _≡_ : ℕ → ℕ → Set where refl : {a : ℕ} → a ≡ a axiom23 : {n : ℕ} → ¬ (zero ≡ (n ++)) axiom23 = λ () axiom24 : {n m : ℕ} → (n ++) ≡ (m ++) → n ≡ m axiom24 refl = refl _+_ : ℕ → ℕ → ℕ -- Definition 2.2.1 zero + m = m (n ++) + m = (n + m) ++ ≡-sec : {n m : ℕ} → n ≡ m → (n ++) ≡ (m ++) ≡-sec refl = refl ≡-comm : {n m : ℕ} → n ≡ m → m ≡ n ≡-comm refl = refl ≡-trans : {n m p : ℕ} → n ≡ m → m ≡ p → n ≡ p ≡-trans refl refl = refl lemma222 : (n : ℕ) → (n + zero) ≡ n lemma222 zero = refl lemma222 (n ++) = ≡-sec (lemma222 n) lemma223 : (n m : ℕ) → (n + (m ++)) ≡ ((n + m) ++) lemma223 zero m = refl lemma223 (n ++) m = ≡-sec (lemma223 n m) -- Addition is commutative prop224 : (n m : ℕ) → (n + m) ≡ (m + n) prop224 zero m = ≡-comm (lemma222 m) prop224 (n ++) m = ≡-trans (≡-sec (prop224 n m)) (≡-comm (lemma223 m n)) -- Addition is associative prop225 : (a b c : ℕ) → ((a + b) + c) ≡ (a + (b + c)) prop225 zero b c = refl prop225 (a ++) b c = ≡-sec (prop225 a b c) -- Cancellation law prop226 : (a b c : ℕ) → (a + b) ≡ (a + c) → b ≡ c prop226 zero b c = λ z → z prop226 (a ++) b c = λ z → (prop226 a b c) (axiom24 z)
# # Draw weak and strong Bruhat diagram # # by Shizuo Kaji # it requires "coxeter and weyl" and "poset" packages by J.Stembridge # http://www.math.lsa.umich.edu/~jrs/maple.html with(posets); with(coxeter); with(weyl); with(WeylOps): # Draw weak (left or right) bruhat diagram # # Example: # H,L := wbruhat(F4, {}, 'L') # plot_poset(H, labels = L, stretch = 1) wbruhat:=proc(R,roots::set:={}, lr::symbol:='L', upto::integer :=0) local H,i,j,w,newweyl,oldweyl,p,pos,wlabel,udim; udim := `if`(upto>0,upto,nops(pos_roots(R))); wlabel:=[[]]; oldweyl:=[[]]; H:=NULL; while nops(wlabel[-1])<udim and nops(oldweyl)>0 do newweyl:=[]; for i from 1 to nops(oldweyl) do for j in {$1..rank(R)} minus roots do w:=`if`(lr='L',reduce([j,op(oldweyl[i])],R),reduce([op(oldweyl[i]),j],R)); if nops(w)=nops(oldweyl[i])+1 then if not member(w, newweyl, 'pos') then H:=H, [nops(wlabel)-nops(oldweyl)+i, nops(wlabel)+nops(newweyl)+1]; newweyl:=[op(newweyl), w]; else H:=H, [nops(wlabel)-nops(oldweyl)+i, nops(wlabel)+pos]; end if; end if; end do; end do; wlabel:=[op(wlabel), op(newweyl)]; oldweyl:=newweyl; end do; return {H},table([seq(i = convert(wlabel[i], 'string'), i = 1 .. nops(wlabel))]): end proc: # Draw strong bruhat diagram # # Example: # H,L,E := wbruhat(F4, {}, 3) # plot_poset(H, labels = L, stretch = 1) # E contains edge labeling sbruhat := proc (R, roots::set:={}, upto::integer:=0) local H, w, r, v, i, j, beta, pos, newvects, newreps, vects, len, reps, oldvects, oldreps, edge, udim,B,P; B := base(R); r := nops(B); P:=pos_roots(R); udim := `if`(upto>0,upto,nops(P)); newvects := [add(weights(R)[i], i={$1..r} minus roots)]; newreps := []; reps := [[]]; vects := newvects; for len from 1 to udim do; oldvects := newvects; oldreps := [newreps]; newvects := []; newreps := NULL; for j to nops(oldvects) do for i to r do if 0 < iprod(B[i], oldvects[j]) then v := reflect(B[i], oldvects[j]); if not member(v, newvects) then newvects := [op(newvects), v]; newreps := newreps, reduce([i, op(oldreps[j])], R) end if end if end do end do; if newreps=NULL then break; end if; reps := [op(reps), newreps]; vects := [op(vects), op(newvects)]; end do; H:= NULL; for j from 1 to nops(vects) do for beta in P do if iprod(beta,vects[j])>0 then v:=reflect(beta,vects[j]); if member(v,vects,'pos') then edge[j,pos]:=root_coords(beta,R); H:= H, [j,pos]; end if; end if; end do; end do; return {H},table([seq(i=[i,reps[i]],i=1..nops(reps))]),edge; end proc; # check if v is minimal w.r.t. a reflection subgroup; has_descent:=proc(w::list,refsub_gen::set,R) local ref; for ref in refsub_gen do if nops(reduce([op(w),op(ref)],R))<nops(w) then return true; end if; end do; return false; end proc: # reduced word w.r.t. a reflection subgroup ref_reduce:=proc(w::list,refsub_gen::set,R) local u,v,neww,is_min; neww:=reduce(w,R); is_min:=false; while is_min=false do; is_min:=true; for u in refsub_gen do v:=reduce([op(neww),op(u)],R); if nops(v)<nops(neww) then neww:=v; is_min:=false; end if; end do; end do; return neww; end proc: # strong bruhat graph w.r.t. a reflection subgroup geenrated by # (non-simple) roots refbruhat:=proc(R,refsub::set:={},upto::integer:=0) local H,i,j,r,u,v,w,len, reps,newreps,oldreps,vects,newvects,oldvects,refsub_gen,udim,pos,ref,P,B,edge; B:=base(R); r:=rank(R); P:=pos_roots(R); udim := `if`(upto>0,upto,nops(P)); refsub_gen:={}; for ref in refsub do; vec2fc(reflect(ref,interior_pt(R)),B,'w'); refsub_gen:={op(refsub_gen),w}; end do; # enumerate reduced words newvects := {interior_pt(R)}; reps := [[]]; newreps := reps; vects := newvects; for len from 1 to udim do; oldvects := newvects; oldreps := newreps; newvects := []; newreps := []; for j to nops(oldvects) do for i to r do if 0 < iprod(B[i], oldvects[j]) then v := reflect(B[i], oldvects[j]); w := reduce([i, op(oldreps[j])], R); if not member(v, newvects) then if not has_descent(w,refsub_gen,R) then newreps := [op(newreps), w]; newvects := [op(newvects), v]; end if; end if end if end do end do; if newreps={} then break; end if; reps := [op(reps), op(newreps)]; vects := [op(vects), op(newvects)]; end do; # edges H:=NULL; for j from 1 to nops(vects) do; for ref in P do if iprod(ref,vects[j])<0 then next; end if; vec2fc(reflect(ref,vects[j]),R,'w'); w:=ref_reduce(w,refsub_gen,R): member(w,reps,'pos'); if j<pos then if assigned(edge[j,pos]) then edge[j,pos]:=[op(edge[j,pos]),root_coords(ref,R)]; else edge[j,pos]:=[root_coords(ref,R)]; H:=H, [j,pos]; end if end if; end do; end do; return {H},table([seq(i = [i,reps[i]], i = 1 .. nops(reps))]),edge: end proc:
# 7 Solution Methods to Solve the Growth Model with Julia This notebook is part of a computational appendix that accompanies the paper > MATLAB, Python, Julia: What to Choose in Economics? > > Coleman, Lyon, Maliar, and Maliar (2017) In order to run the codes in this notebook you will need to install and configure a few Julia packages. We recommend following the instructions on [quantecon.org](https://lectures.quantecon.org/jl/getting_started.html). Once your Julia installation is up and running, there are a few additional packages you will need in order to run the code here. To do this uncomment the lines in the cell below (by deleting the `#` and space at the beginning of each line) and run the cell: ```julia using Pkg pkg"add InstantiateFromURL" ```  Updating registry at `~/.julia/registries/General`  Updating git-repo `https://github.com/JuliaRegistries/General.git` [?25l[?25h Resolving package versions...  Updating `~/.julia/environments/v1.1/Project.toml`  [no changes]  Updating `~/.julia/environments/v1.1/Manifest.toml`  [no changes] ```julia using InstantiateFromURL: activate_github_path activate_github_path("sglyon/CLMMJuliaPythonMatlab", path="Growth/julia", activate=true, force=true) ``` ┌ Info: Recompiling stale cache file /Users/sglyon/.julia/compiled/v1.1/InstantiateFromURL/vAXbt.ji for InstantiateFromURL [43edad99-fa64-5e4f-9937-1c09a410b73f] └ @ Base loading.jl:1184  Updating registry at `~/.julia/registries/General`  Updating git-repo `https://github.com/JuliaRegistries/General.git` [?25l[?25hPrecompiling project... ```julia using Printf, Random, LinearAlgebra using BasisMatrices, Optim, QuantEcon, Parameters using BasisMatrices: Degree, Derivative ``` ┌ Info: Recompiling stale cache file /Users/sglyon/.julia/compiled/v1.1/BasisMatrices/65PSC.ji for BasisMatrices [08854c51-b66b-5062-a90d-8e7ae4547a49] └ @ Base loading.jl:1184 ## Model This section gives a short description of the commonly used stochastic Neoclassical growth model. There is a single infinitely-lived representative agent who consumes and saves using capital. The consumer discounts the future with factor $\beta$ and derives utility from only consumption. Additionally, saved capital will depreciate at $\delta$. The consumer has access to a Cobb-Douglas technology which uses capital saved from the previous period to produce and is subject to stochastic productivity shocks. Productivity shocks follow an AR(1) in logs. The agent's problem can be written recursively using the following Bellman equation \begin{align} V(k_t, z_t) &= \max_{k_{t+1}} u(c_t) + \beta E \left[ V(k_{t+1}, z_{t+1}) \right] \\ &\text{subject to } \\ c_t &= z_t f(k_t) + (1 - \delta) k_t - k_{t+1} \\ \log z_{t+1} &= \rho \log z_t + \sigma \varepsilon \end{align} ## Julia Code We begin by defining a type that describes our model. It will hold the three things 1. Parameters of the growth model 2. Grids used for approximating the solution 3. Nodes and weights used to approximate integration Note the `@with_kw` comes from the `Parameters` package -- It allows one to specify default arguments for the parameters when building a type (for more information refer to their [documentation](http://parametersjl.readthedocs.io/en/latest/)). One of the benefits of using the `Parameters` package is their code allows us to do things like, `@unpack a, b, c = Params` which takes elements from inside the type `Params` and "unpacks" them... i.e. it automates code of the form `a, b, c = Params.a, Params.b, Params.c` ```julia """ The stochastic Neoclassical growth model type contains parameters which define the model * α: Capital share in output * β: Discount factor * δ: Depreciation rate * γ: Risk aversion * ρ: Persistence of the log of the productivity level * σ: Standard deviation of shocks to log productivity level * A: Coefficient on C-D production function * kgrid: Grid over capital * zgrid: Grid over productivity * grid: Grid of (k, z) pairs * eps_nodes: Nodes used to integrate * weights: Weights used to integrate * z1: A grid of the possible z1s tomorrow given eps_nodes and zgrid """ @with_kw struct NeoclassicalGrowth # Parameters α::Float64 = 0.36 β::Float64 = 0.99 δ::Float64 = 0.02 γ::Float64 = 2.0 ρ::Float64 = 0.95 σ::Float64 = 0.01 A::Float64 = (1.0/β - (1 - δ)) / α # Grids kgrid::Vector{Float64} = collect(range(0.9, stop=1.1, length=10)) zgrid::Vector{Float64} = collect(range(0.9, stop=1.1, length=10)) grid::Matrix{Float64} = gridmake(kgrid, zgrid) eps_nodes::Vector{Float64} = qnwnorm(5, 0.0, σ^2)[1] weights::Vector{Float64} = qnwnorm(5, 0.0, σ^2)[2] z1::Matrix{Float64} = (zgrid.^(ρ))' .* exp.(eps_nodes) end ``` NeoclassicalGrowth We also define some useful functions so that we [don't repeat ourselves](https://lectures.quantecon.org/py/writing_good_code.html#don-t-repeat-yourself) later in the code. ```julia # Helper functions f(ncgm::NeoclassicalGrowth, k, z) = @. z * (ncgm.A * k^ncgm.α) df(ncgm::NeoclassicalGrowth, k, z) = @. ncgm.α * z * (ncgm.A * k^(ncgm.α - 1.0)) u(ncgm::NeoclassicalGrowth, c) = c > 1e-10 ? @.(c^(1-ncgm.γ)-1)/(1-ncgm.γ) : -1e10 du(ncgm::NeoclassicalGrowth, c) = c > 1e-10 ? c.^(-ncgm.γ) : 1e10 duinv(ncgm::NeoclassicalGrowth, u) = u .^ (-1 / ncgm.γ) expendables_t(ncgm::NeoclassicalGrowth, k, z) = (1-ncgm.δ)*k + f(ncgm, k, z) ``` expendables_t (generic function with 1 method) ## Solution Methods In this notebook, we describe the following solution methods: * Conventional Value Function Iteration * Envelope Condition Value Function Iteration * Envelope Condition Derivative Value Function Iteration * Endogenous Grid Value Function Iteration * Conventional Policy Function Iteration * Envelope Condition Policy Function Iteration * Euler Equation Method Each of these solution methods will have a very similar structure that follows a few basic steps: 1. Guess a function (either value function or policy function). 2. Using this function, update our guess of both the value and policy functions. 3. Check whether the function we guessed and what it was updated to are similar enough. If so, proceed. If not, return to step 2 using the newly updated functions. 4. Output the policy and value functions. In order to reduce the amount of repeated code and keep the exposition as clean as possible (the notebook is plenty long as is...), we will define multiple solution types that will have a more general (abstract) type called `SolutionMethod`. A solution can then be characterized by a concrete type `ValueCoeffs` (a special case for each solution method) which consists of an approximation degree, coefficients for the value function, and coefficients for the policy function. The rest of the functions below that are just more helper methods. We will then define a general solve method that applies steps 1, 3, and 4 from the algorithm above. Finally, we will implement a special method to do step 2 for each of the algorithms. These implementation may seem a bit confusing at first (though hopefully the idea itself feels intuitive) -- The implementation takes advantage of a powerful type system in Julia. ```julia # Types for solution methods abstract type SolutionMethod end struct IterateOnPolicy <: SolutionMethod end struct VFI_ECM <: SolutionMethod end struct VFI_EGM <: SolutionMethod end struct VFI <: SolutionMethod end struct PFI_ECM <: SolutionMethod end struct PFI <: SolutionMethod end struct dVFI_ECM <: SolutionMethod end struct EulEq <: SolutionMethod end # # Type for Approximating Value and Policy # mutable struct ValueCoeffs{T <: SolutionMethod,D <: Degree} d::D v_coeffs::Vector{Float64} k_coeffs::Vector{Float64} end function ValueCoeffs(::Type{Val{d}}, method::T) where T <: SolutionMethod where d # Initialize two vectors of zeros deg = Degree{d}() n = n_complete(2, deg) v_coeffs = zeros(n) k_coeffs = zeros(n) return ValueCoeffs{T,Degree{d}}(deg, v_coeffs, k_coeffs) end function ValueCoeffs( ncgm::NeoclassicalGrowth, ::Type{Val{d}}, method::T ) where T <: SolutionMethod where d # Initialize with vector of zeros deg = Degree{d}() n = n_complete(2, deg) v_coeffs = zeros(n) # Policy guesses based on k and z k, z = ncgm.grid[:, 1], ncgm.grid[:, 2] css = ncgm.A - ncgm.δ yss = ncgm.A c_pol = f(ncgm, k, z) * (css/yss) # Figure out what kp is k_pol = expendables_t(ncgm, k, z) - c_pol k_coeffs = complete_polynomial(ncgm.grid, d) \ k_pol return ValueCoeffs{T,Degree{d}}(deg, v_coeffs, k_coeffs) end solutionmethod(::ValueCoeffs{T}) where T <:SolutionMethod = T # A few copy methods to make life easier Base.copy(vp::ValueCoeffs{T,D}) where T where D = ValueCoeffs{T,D}(vp.d, vp.v_coeffs, vp.k_coeffs) function Base.copy(vp::ValueCoeffs{T1,D}, ::T2) where T1 where D where T2 <: SolutionMethod ValueCoeffs{T2,D}(vp.d, vp.v_coeffs, vp.k_coeffs) end function Base.copy( ncgm::NeoclassicalGrowth, vp::ValueCoeffs{T}, ::Type{Val{new_degree}} ) where T where new_degree # Build Value and policy matrix deg = Degree{new_degree}() V = build_V(ncgm, vp) k = build_k(ncgm, vp) # Build new Phi Phi = complete_polynomial(ncgm.grid, deg) v_coeffs = Phi \ V k_coeffs = Phi \ k return ValueCoeffs{T,Degree{new_degree}}(deg, v_coeffs, k_coeffs) end ``` We will need to repeatedly update coefficients, build $V$ (or $dV$ depending on the solution method), and be able to compute expected values, so we define some additional helper functions below. ```julia """ Updates the coefficients for the value function inplace in `vp` """ function update_v!(vp::ValueCoeffs, new_coeffs::Vector{Float64}, dampen::Float64) vp.v_coeffs = (1-dampen)*vp.v_coeffs + dampen*new_coeffs end """ Updates the coefficients for the policy function inplace in `vp` """ function update_k!(vp::ValueCoeffs, new_coeffs::Vector{Float64}, dampen::Float64) vp.k_coeffs = (1-dampen)*vp.k_coeffs + dampen*new_coeffs end """ Builds either V or dV depending on the solution method that is given. If it is a solution method that iterates on the derivative of the value function then it will return derivative of the value function, otherwise the value function itself """ build_V_or_dV(ncgm::NeoclassicalGrowth, vp::ValueCoeffs) = build_V_or_dV(ncgm, vp, solutionmethod(vp)()) build_V_or_dV(ncgm, vp::ValueCoeffs, ::SolutionMethod) = build_V(ncgm, vp) build_V_or_dV(ncgm, vp::ValueCoeffs, T::dVFI_ECM) = build_dV(ncgm, vp) function build_dV(ncgm::NeoclassicalGrowth, vp::ValueCoeffs) Φ = complete_polynomial(ncgm.grid, vp.d, Derivative{1}()) Φ*vp.v_coeffs end function build_V(ncgm::NeoclassicalGrowth, vp::ValueCoeffs) Φ = complete_polynomial(ncgm.grid, vp.d) Φ*vp.v_coeffs end function build_k(ncgm::NeoclassicalGrowth, vp::ValueCoeffs) Φ = complete_polynomial(ncgm.grid, vp.d) Φ*vp.k_coeffs end ``` build_k (generic function with 1 method) Additionally, in order to evaluate the value function, we will need to be able to take expectations. These functions evaluates expectations by taking the policy $k_{t+1}$ and the current productivity state $z_t$ as inputs. They then integrates over the possible $z_{t+1}$s. ```julia function compute_EV!(cp_kpzp::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs, kp, iz) # Pull out information from types z1, weightsz = ncgm.z1, ncgm.weights # Get number nodes nzp = length(weightsz) EV = 0.0 for izp in 1:nzp zp = z1[izp, iz] complete_polynomial!(cp_kpzp, [kp, zp], vp.d) EV += weightsz[izp] * dot(vp.v_coeffs, cp_kpzp) end return EV end function compute_EV(ncgm::NeoclassicalGrowth, vp::ValueCoeffs, kp, iz) cp_kpzp = Array{Float64}(undef, n_complete(2, vp.d)) return compute_EV!(cp_kpzp, ncgm, vp, kp, iz) end function compute_EV(ncgm::NeoclassicalGrowth, vp::ValueCoeffs) # Get length of k and z grids kgrid, zgrid = ncgm.kgrid, ncgm.zgrid nk, nz = length(kgrid), length(zgrid) temp = Array{Float64}(undef, n_complete(2, vp.d)) # Allocate space to store EV EV = Array{Float64}(undef, nk*nz) _inds = LinearIndices((nk, nz)) for ik in 1:nk, iz in 1:nz # Pull out states k = kgrid[ik] z = zgrid[iz] ikiz_index = _inds[ik, iz] # Pass to scalar EV complete_polynomial!(temp, [k, z], vp.d) kp = dot(vp.k_coeffs, temp) EV[ikiz_index] = compute_EV!(temp, ncgm, vp, kp, iz) end return EV end function compute_dEV!(cp_dkpzp::Vector, ncgm::NeoclassicalGrowth, vp::ValueCoeffs, kp, iz) # Pull out information from types z1, weightsz = ncgm.z1, ncgm.weights # Get number nodes nzp = length(weightsz) dEV = 0.0 for izp in 1:nzp zp = z1[izp, iz] complete_polynomial!(cp_dkpzp, [kp, zp], vp.d, Derivative{1}()) dEV += weightsz[izp] * dot(vp.v_coeffs, cp_dkpzp) end return dEV end function compute_dEV(ncgm::NeoclassicalGrowth, vp::ValueCoeffs, kp, iz) compute_dEV!(Array{Float64}(undef, n_complete(2, vp.d)), ncgm, vp, kp, iz) end ``` compute_dEV (generic function with 1 method) ### General Solution Method As promised, below is some code that "generally" applies the algorithm that we described -- Notice that it is implemented for a type `ValueCoeffs{SolutionMethod}` which is our abstract type. We will define a special version of `update` for each solution method and then we will only need this one `solve` method and won't repeat the more tedious portions of our code. ```julia function solve( ncgm::NeoclassicalGrowth, vp::ValueCoeffs; tol::Float64=1e-6, maxiter::Int=5000, dampen::Float64=1.0, nskipprint::Int=1, verbose::Bool=true ) # Get number of k and z on grid nk, nz = length(ncgm.kgrid), length(ncgm.zgrid) # Build basis matrix and value function dPhi = complete_polynomial(ncgm.grid, vp.d, Derivative{1}()) Phi = complete_polynomial(ncgm.grid, vp.d) V = build_V_or_dV(ncgm, vp) k = build_k(ncgm, vp) Vnew = copy(V) knew = copy(k) # Print column names if verbose @printf("| Iteration | Distance V | Distance K |\n") end # Iterate to convergence dist, iter = 10.0, 0 while (tol < dist) & (iter < maxiter) # Update the value function using appropriate update methods update!(Vnew, knew, ncgm, vp, Phi, dPhi) # Compute distance and update all relevant elements iter += 1 dist_v = maximum(abs, 1.0 .- Vnew./V) dist_k = maximum(abs, 1.0 .- knew./k) copy!(V, Vnew) copy!(k, knew) # If we are iterating on a policy, use the difference of values # otherwise use the distance on policy dist = ifelse(solutionmethod(vp) == IterateOnPolicy, dist_v, dist_k) # Print status update if verbose && (iter%nskipprint == 0) @printf("|%-11d|%-12e|%-12e|\n", iter, dist_v, dist_k) end end # Update value and policy functions one last time as long as the # solution method isn't IterateOnPolicy if ~(solutionmethod(vp) == IterateOnPolicy) # Update capital policy after finished kp = env_condition_kp(ncgm, vp) update_k!(vp, complete_polynomial(ncgm.grid, vp.d) \ kp, 1.0) # Update value function according to specified policy vp_igp = copy(vp, IterateOnPolicy()) solve(ncgm, vp_igp; tol=1e-10, maxiter=5000, verbose=false) update_v!(vp, vp_igp.v_coeffs, 1.0) end return vp end ``` solve (generic function with 1 method) ### Iterating to Convergence (given policy) This isn't one of the methods described above, but it is used as an element of a few of our methods (and also as a way to get a first guess at the value function). This method takes an initial policy function, $\bar{k}(k_t, z_t)$, as given, and then, without changing the policy, iterates until the value function has converged. Thus the "update section" of the algorithm in this instance would be: * Leave policy function unchanged * At each point of grid, $(k_t, z_t)$, compute $\hat{V}(k_t, z_t) = u(c(\bar{k}(k_t, z_t))) + \beta E \left[ V(\bar{k}(k_t, z_t), z_{t+1}) \right]$ ```julia function update!(V::Vector{Float64}, kpol::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs{IterateOnPolicy}, Φ::Matrix{Float64}, dΦ::Matrix{Float64}) # Get sizes and allocate for complete_polynomial kgrid = ncgm.kgrid; zgrid = ncgm.zgrid; nk, nz = length(kgrid), length(zgrid) _inds = LinearIndices((nk, nz)) # Iterate over all states for ik in 1:nk, iz in 1:nz # Pull out states k = kgrid[ik] z = zgrid[iz] # Pull out policy and evaluate consumption ikiz_index = _inds[ik, iz] k1 = kpol[ikiz_index] c = expendables_t(ncgm, k, z) - k1 # New value EV = compute_EV(ncgm, vp, k1, iz) V[ikiz_index] = u(ncgm, c) + ncgm.β*EV end # Update coefficients update_v!(vp, Φ \ V, 1.0) update_k!(vp, Φ \ kpol, 1.0) return V end ``` update! (generic function with 1 method) ### Conventional Value Function Iteration This is one of the first solution methods for macroeconomics a graduate student in economics typically learns. In this solution method, one takes as given a value function, $V(k_t, z_t)$, and then solves for the optimal policy given the value function. The update section takes the form: * For each point, $(k_t, z_t)$, numerically solve for $c^*(k_t, z_t)$ to satisfy the first order condition $u'(c^*) = \beta E \left[ V_1((1 - \delta) k_t + z_t f(k_t) - c^*, z_{t+1}) \right]$ * Define $k^*(k_t, z_t) = (1 - \delta) k_t + z_t f(k_t) - c^*(k_t, z_t)$ * Update value function according to $\hat{V}(k_t, z_t) = u(c^*(k_t, z_t)) + \beta E \left[ V(k^*(k_t, z_t), z_{t+1}) \right]$ ```julia function update!(V::Vector{Float64}, kpol::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs{VFI}, Φ::Matrix{Float64}, dΦ::Matrix{Float64}) # Get sizes and allocate for complete_polynomial kgrid = ncgm.kgrid; zgrid = ncgm.zgrid nk, nz = length(kgrid), length(zgrid) # Iterate over all states temp = Array{Float64}(undef, n_complete(2, vp.d)) _inds = LinearIndices((nk, nz)) for iz=1:nz, ik=1:nk k = kgrid[ik]; z = zgrid[iz] # Define an objective function (negative for minimization) y = expendables_t(ncgm, k, z) solme(kp) = du(ncgm, y - kp) - ncgm.β*compute_dEV!(temp, ncgm, vp, kp, iz) # Find sol to foc kp = brent(solme, 1e-8, y-1e-8; rtol=1e-12) c = expendables_t(ncgm, k, z) - kp # New value ikiz_index = _inds[ik, iz] EV = compute_EV!(temp, ncgm, vp, kp, iz) V[ikiz_index] = u(ncgm, c) + ncgm.β*EV kpol[ikiz_index] = kp end # Update coefficients update_v!(vp, Φ \ V, 1.0) update_k!(vp, Φ \ kpol, 1.0) return V end ``` update! (generic function with 2 methods) ### Endogenous Grid Value Function Iteration Method introduced by Chris Carroll. The key to this method is that the grid of points being used to approximate is over $(k_{t+1}, z_{t})$ instead of $(k_t, z_t)$. The insightful piece of this algorithm is that the transformation allows one to write a closed form for the consumption function, $c^*(k_{t+1}, z_t) = u'^{-1} \left( V_1(k_{t+1}, z_{t+1}) \right]$. Then for a given $(k_{t+1}, z_{t})$ the update section would be * Define $c^*(k_{t+1}, z_t) = u'^{-1} \left( \beta E \left[ V_1(k_{t+1}, z_{t+1}) \right] \right)$ * Find $k_t$ such that $k_t = (1 - \delta) k_t + z_t f(k_t) - k_{t+1}$ * Update value function according to $\hat{V}(k_t, z_t) = u(c^*(k_{t+1}, z_t)) + \beta E \left[ V(k_{t+1}, z_{t+1}) \right]$ ```julia function update!(V::Vector{Float64}, kpol::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs{VFI_EGM}, Φ::Matrix{Float64}, dΦ::Matrix{Float64}) # Get sizes and allocate for complete_polynomial kgrid = ncgm.kgrid; zgrid = ncgm.zgrid; grid = ncgm.grid; nk, nz = length(kgrid), length(zgrid) # Iterate temp = Array{Float64}(undef, n_complete(2, vp.d)) _inds = LinearIndices((nk, nz)) for iz=1:nz, ik=1:nk # In EGM we use the grid points as if they were our # policy for yesterday and find implied kt ikiz_index = _inds[ik, iz] k1 = kgrid[ik];z = zgrid[iz]; # Compute the derivative of expected values dEV = compute_dEV!(temp, ncgm, vp, k1, iz) # Compute optimal consumption c = duinv(ncgm, ncgm.β*dEV) # Need to find corresponding kt for optimal c obj(kt) = expendables_t(ncgm, kt, z) - c - k1 kt_star = brent(obj, 0.0, 2.0, xtol=1e-10) # New value EV = compute_EV!(temp, ncgm, vp, k1, iz) V[ikiz_index] = u(ncgm, c) + ncgm.β*EV kpol[ikiz_index] = kt_star end # New Φ (has our new "kt_star" and z points) Φ_egm = complete_polynomial([kpol grid[:, 2]], vp.d) # Update coefficients update_v!(vp, Φ_egm \ V, 1.0) update_k!(vp, Φ_egm \ grid[:, 1], 1.0) # Update V and kpol to be value and policy corresponding # to our grid again copy!(V, Φ*vp.v_coeffs) copy!(kpol, Φ*vp.k_coeffs) return V end ``` update! (generic function with 3 methods) ### Envelope Condition Value Function Iteration Very similar to the previous method. The insight of this algorithm is that since we are already approximating the value function and can evaluate its derivative, we can skip the numerical optimization piece of the update method and compute directly the policy using the envelope condition (hence the name). The envelope condition says: $$c^*(k_t, z_t) = u'^{-1} \left( \frac{\partial V(k_t, z_t)}{\partial k_t} (1 - \delta + r)^{-1} \right)$$ so $$k^*(k_t, z_t) = z_t f(k_t) + (1-\delta)k_t - c^*(k_t, z_t)$$ The functions below compute the policy using the envelope condition. ```julia function env_condition_kp!(cp_out::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs, k::Float64, z::Float64) # Compute derivative of VF dV = dot(vp.v_coeffs, complete_polynomial!(cp_out, [k, z], vp.d, Derivative{1}())) # Consumption is then computed as c = duinv(ncgm, dV / (1 - ncgm.δ .+ df(ncgm, k, z))) return expendables_t(ncgm, k, z) - c end function env_condition_kp(ncgm::NeoclassicalGrowth, vp::ValueCoeffs, k::Float64, z::Float64) cp_out = Array{Float64}(undef, n_complete(2, vp.d)) env_condition_kp!(cp_out, ncgm, vp, k, z) end function env_condition_kp(ncgm::NeoclassicalGrowth, vp::ValueCoeffs) # Pull out k and z from grid k = ncgm.grid[:, 1] z = ncgm.grid[:, 2] # Create basis matrix for entire grid dPhi = complete_polynomial(ncgm.grid, vp.d, Derivative{1}()) # Compute consumption c = duinv(ncgm, (dPhi*vp.v_coeffs) ./ (1-ncgm.δ.+df(ncgm, k, z))) return expendables_t(ncgm, k, z) .- c end ``` env_condition_kp (generic function with 2 methods) The update method is then very similar to other value iteration style methods, but avoids the numerical solver. * For each point, $(k_t, z_t)$ get $c^*(k_t, z_t)$ from the envelope condition * Define $k^*(k_t, z_t) = (1 - \delta) k_t + z_t f(k_t) - c^*(k_t, z_t)$ * Update value function according to $\hat{V}(k_t, z_t) = u(c^*(k_t, z_t)) + \beta E \left[ V(k^*(k_t, z_t), z_{t+1}) \right]$ ```julia function update!(V::Vector{Float64}, kpol::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs{VFI_ECM}, Φ::Matrix{Float64}, dΦ::Matrix{Float64}) # Get sizes and allocate for complete_polynomial kgrid = ncgm.kgrid; zgrid = ncgm.zgrid; nk, nz = length(kgrid), length(zgrid) # Iterate over all states temp = Array{Float64}(undef, n_complete(2, vp.d)) _inds = LinearIndices((nk, nz)) for ik in 1:nk, iz in 1:nz ikiz_index = _inds[ik, iz] k = kgrid[ik] z = zgrid[iz] # Policy from envelope condition kp = env_condition_kp!(temp, ncgm, vp, k, z) c = expendables_t(ncgm, k, z) - kp kpol[ikiz_index] = kp # New value EV = compute_EV!(temp, ncgm, vp, kp, iz) V[ikiz_index] = u(ncgm, c) + ncgm.β*EV end # Update coefficients update_v!(vp, Φ \ V, 1.0) update_k!(vp, Φ \ kpol, 1.0) return V end ``` update! (generic function with 4 methods) ### Conventional Policy Function Iteration Policy function iteration is different than value function iteration in that it starts with a policy function, then updates the value function, and finally finds the new optimal policy function. Given a policy $c(k_t, z_t)$ and for each pair $(k_t, z_t)$ * Define $k(k_t, z_t) = (1 - \delta) k_t + z_t f(k_t) - c(k_t, z_t)$ * Find fixed point of $V(k_t, z_t) = u(c(k_t, z_t)) + \beta E \left[ V(k(k_t, z_t), z_t) \right]$ (Iterate to convergence given policy) * Given $V(k_t, z_t)$, numerically solve for new policy $c^*(k_t, z_t)$ -- Stop when $c(k_t, z_t) \approx c^*(k_t, z_t)$ ```julia function update!(V::Vector{Float64}, kpol::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs{PFI}, Φ::Matrix{Float64}, dΦ::Matrix{Float64}) # Get sizes and allocate for complete_polynomial kgrid = ncgm.kgrid; zgrid = ncgm.zgrid; grid = ncgm.grid; nk, nz = length(kgrid), length(zgrid) # Copy valuecoeffs object and use to iterate to # convergence given a policy vp_igp = copy(vp, IterateOnPolicy()) solve(ncgm, vp_igp; nskipprint=1000, maxiter=5000, verbose=false) # Update the policy and values temp = Array{Float64}(undef, n_complete(2, vp.d)) _inds = LinearIndices((nk, nz)) for ik in 1:nk, iz in 1:nz k = kgrid[ik]; z = zgrid[iz]; # Define an objective function (negative for minimization) y = expendables_t(ncgm, k, z) solme(kp) = du(ncgm, y - kp) - ncgm.β*compute_dEV!(temp, ncgm, vp, kp, iz) # Find minimum of objective kp = brent(solme, 1e-8, y-1e-8; rtol=1e-12) # Update policy function ikiz_index = _inds[ik, iz] kpol[ikiz_index] = kp end # Get new coeffs update_k!(vp, Φ \ kpol, 1.0) update_v!(vp, vp_igp.v_coeffs, 1.0) # Update all elements of value copy!(V, Φ*vp.v_coeffs) return V end ``` update! (generic function with 5 methods) ### Envelope Condition Policy Function Iteration Similar to policy function iteration, but, rather than numerically solve for new policies, it uses the envelope condition to directly compute them. Given a starting policy $c(k_t, z_t)$ and for each pair $(k_t, z_t)$ * Define $k(k_t, z_t) = (1 - \delta) k_t + z_t f(k_t) - c(k_t, z_t)$ * Find fixed point of $V(k_t, z_t) = u(c(k_t, z_t)) + \beta E \left[ V(k(k_t, z_t), z_t) \right]$ (Iterate to convergence given policy) * Given $V(k_t, z_t)$ find $c^*(k_t, z_t)$ using envelope condition -- Stop when $c(k_t, z_t) \approx c^*(k_t, z_t)$ ```julia function update!(V::Vector{Float64}, kpol::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs{PFI_ECM}, Φ::Matrix{Float64}, dΦ::Matrix{Float64}) # Copy valuecoeffs object and use to iterate to # convergence given a policy vp_igp = copy(vp, IterateOnPolicy()) solve(ncgm, vp_igp; nskipprint=1000, maxiter=5000, verbose=false) # Update the policy and values kp = env_condition_kp(ncgm, vp) update_k!(vp, Φ \ kp, 1.0) update_v!(vp, vp_igp.v_coeffs, 1.0) # Update all elements of value copy!(V, Φ*vp.v_coeffs) copy!(kpol, kp) return V end ``` update! (generic function with 6 methods) ### Euler Equation Method Euler equation methods operate directly on the Euler equation: $u'(c_t) = \beta E \left[ u'(c_{t+1}) (1 - \delta + z_t f'(k_t)) \right]$. Given an initial policy $c(k_t, z_t)$ for each grid point $(k_t, z_t)$ * Find $k(k_t, z_t) = (1-\delta)k_t + z_t f(k_t) - c(k_t, z_t)$ * Let $c_{t+1} = c(k(k_t, z_t), z_t)$ * Numerically solve for a $c^*$ that satisfies the Euler equation i.e. $u'(c^*) = \beta E \left[ u'(c_{t+1}) (1 - \delta + z_t f'(k_t)) \right]$ * Stop when $c^*(k_t, z_t) \approx c(k_t, z_t)$ ```julia # Conventional Euler equation method function update!(V::Vector{Float64}, kpol::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs{EulEq}, Φ::Matrix{Float64}, dΦ::Matrix{Float64}) # Get sizes and allocate for complete_polynomial @unpack kgrid, zgrid, weights, z1 = ncgm nz1, nz = size(z1) nk = length(kgrid) # Iterate over all states temp = Array{Float64}(undef, n_complete(2, vp.d)) _inds = LinearIndices((nk, nz)) for iz in 1:nz, ik in 1:nk k = kgrid[ik]; z = zgrid[iz]; # Create current polynomial complete_polynomial!(temp, [k, z], vp.d) # Compute what capital will be tomorrow according to policy kp = dot(temp, vp.k_coeffs) # Compute RHS of EE rhs_ee = 0.0 for iz1 in 1:nz1 # Possible z in t+1 zp = z1[iz1, iz] # Policy for k_{t+2} complete_polynomial!(temp, [kp, zp], vp.d) kpp = dot(temp, vp.k_coeffs) # Implied t+1 consumption cp = expendables_t(ncgm, kp, zp) - kpp # Add to running expectation rhs_ee += ncgm.β*weights[iz1]*du(ncgm, cp)*(1-ncgm.δ+df(ncgm, kp, zp)) end # The rhs of EE implies consumption and investment in t c = duinv(ncgm, rhs_ee) kp_star = expendables_t(ncgm, k, z) - c # New value ikiz_index = _inds[ik, iz] EV = compute_EV!(temp, ncgm, vp, kp_star, iz) V[ikiz_index] = u(ncgm, c) + ncgm.β*EV kpol[ikiz_index] = kp_star end # Update coefficients update_v!(vp, Φ \ V, 1.0) update_k!(vp, Φ \ kpol, 1.0) return V end ``` update! (generic function with 7 methods) ### Envelope Condition Derivative Value Function Iteration This method uses the same insight of the "Envelope Condition Value Function Iteration," but, rather than iterate directly on the value function, it iterates on the derivative of the value function. The update steps are * For each point, $(k_t, z_t)$ get $c^*(k_t, z_t)$ from the envelope condition (which only depends on the derivative of the value function!) * Define $k^*(k_t, z_t) = (1 - \delta) k_t + z_t f(k_t) - c^*(k_t, z_t)$ * Update value function according to $\hat{V}_1(k_t, z_t) = \beta (1 - \delta + z_t f'(k_t)) E \left[ V_1(k^*(k_t, z_t), z_{t+1}) \right]$ Once it has converged, you use the implied policy rule and iterate to convergence using the "iterate to convergence (given policy)" method. ```julia function update!(dV::Vector{Float64}, kpol::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs{dVFI_ECM}, Φ::Matrix{Float64}, dΦ::Matrix{Float64}) # Get sizes and allocate for complete_polynomial kgrid = ncgm.kgrid; zgrid = ncgm.zgrid; grid = ncgm.grid; nk, nz, ns = length(kgrid), length(zgrid), size(grid, 1) # Iterate over all states temp = Array{Float64}(undef, n_complete(2, vp.d)) _inds = LinearIndices((nk, nz)) for iz=1:nz, ik=1:nk k = kgrid[ik]; z = zgrid[iz]; # Envelope condition implies optimal kp kp = env_condition_kp!(temp, ncgm, vp, k, z) c = expendables_t(ncgm, k, z) - kp # New value ikiz_index = _inds[ik, iz] dEV = compute_dEV!(temp, ncgm, vp, kp, iz) dV[ikiz_index] = (1-ncgm.δ+df(ncgm, k, z))*ncgm.β*dEV kpol[ikiz_index] = kp end # Get new coeffs update_k!(vp, Φ \ kpol, 1.0) update_v!(vp, dΦ \ dV, 1.0) return dV end ``` update! (generic function with 8 methods) ### Simulation and Euler Error Methods The following functions to simulate and compute Euler errors are easily defined given our model type and the solution type. ```julia """ Simulates the neoclassical growth model for a given set of solution coefficients. It simulates for `capT` periods and discards first `nburn` observations. """ function simulate(ncgm::NeoclassicalGrowth, vp::ValueCoeffs, shocks::Vector{Float64}; capT::Int=10_000, nburn::Int=200) # Unpack parameters kp = 0.0 # Policy holder temp = Array{Float64}(undef, n_complete(2, vp.d)) # Allocate space for k and z ksim = Array{Float64}(undef, capT+nburn) zsim = Array{Float64}(undef, capT+nburn) # Initialize both k and z at 1 ksim[1] = 1.0 zsim[1] = 1.0 # Simulate temp = Array{Float64}(undef, n_complete(2, vp.d)) for t in 2:capT+nburn # Evaluate k_t given yesterday's (k_{t-1}, z_{t-1}) kp = env_condition_kp!(temp, ncgm, vp, ksim[t-1], zsim[t-1]) # Draw new z and update k using policy above zsim[t] = zsim[t-1]^ncgm.ρ * exp(ncgm.σ*shocks[t]) ksim[t] = kp end return ksim[nburn+1:end], zsim[nburn+1:end] end function simulate(ncgm::NeoclassicalGrowth, vp::ValueCoeffs; capT::Int=10_000, nburn::Int=200, seed=42) Random.seed!(seed) # Set specific seed shocks = randn(capT + nburn) return simulate(ncgm, vp, shocks; capT=capT, nburn=nburn) end """ This function evaluates the Euler Equation residual for a single point (k, z) """ function EulerEquation!(out::Vector{Float64}, ncgm::NeoclassicalGrowth, vp::ValueCoeffs, k::Float64, z::Float64, nodes::Vector{Float64}, weights::Vector{Float64}) # Evaluate consumption today k1 = env_condition_kp!(out, ncgm, vp, k, z) c = expendables_t(ncgm, k, z) - k1 LHS = du(ncgm, c) # For each of realizations tomorrow, evaluate expectation on RHS RHS = 0.0 for (eps, w) in zip(nodes, weights) # Compute ztp1 z1 = z^ncgm.ρ * exp(eps) # Evaluate the ktp2 ktp2 = env_condition_kp!(out, ncgm, vp, k1, z1) # Get c1 c1 = expendables_t(ncgm, k1, z1) - ktp2 # Update RHS of equation RHS = RHS + w*du(ncgm, c1)*(1 - ncgm.δ + df(ncgm, k1, z1)) end return abs(ncgm.β*RHS/LHS - 1.0) end """ Given simulations for k and z, it computes the euler equation residuals along the entire simulation. It reports the mean and max values in log10. """ function ee_residuals(ncgm::NeoclassicalGrowth, vp::ValueCoeffs, ksim::Vector{Float64}, zsim::Vector{Float64}; Qn::Int=10) # Figure out how many periods we simulated for and make sure k and z # are same length capT = length(ksim) @assert length(zsim) == capT # Finer integration nodes eps_nodes, weight_nodes = qnwnorm(Qn, 0.0, ncgm.σ^2) temp = Array{Float64}(undef, n_complete(2, vp.d)) # Compute EE for each period EE_resid = Array{Float64}(undef, capT) for t=1:capT # Pull out current state k, z = ksim[t], zsim[t] # Compute residual of Euler Equation EE_resid[t] = EulerEquation!(temp, ncgm, vp, k, z, eps_nodes, weight_nodes) end return EE_resid end function ee_residuals(ncgm::NeoclassicalGrowth, vp::ValueCoeffs; Qn::Int=10) # Simulate and then call other ee_residuals method ksim, zsim = simulate(ncgm, vp) return ee_residuals(ncgm, vp, ksim, zsim; Qn=Qn) end ``` ee_residuals (generic function with 2 methods) ## A Horse Race We can now run a horse race to compare the methods in terms of both accuracy and speed. ```julia function main(sm::SolutionMethod, nd::Int=5, shocks=randn(capT+nburn); capT=10_000, nburn=200, tol=1e-9, maxiter=2500, nskipprint=25, verbose=true) # Create model ncgm = NeoclassicalGrowth() # Create initial quadratic guess vp = ValueCoeffs(ncgm, Val{2}, IterateOnPolicy()) solve(ncgm, vp; tol=1e-6, verbose=false) # Allocate memory for timings times = Array{Float64}(undef, nd-1) sols = Array{ValueCoeffs}(undef, nd-1) mean_ees = Array{Float64}(undef, nd-1) max_ees = Array{Float64}(undef, nd-1) # Solve using the solution method for degree 2 to 5 vp = copy(vp, sm) for d in 2:nd # Change degree of solution method vp = copy(ncgm, vp, Val{d}) # Time the current method start_time = time() solve(ncgm, vp; tol=tol, maxiter=maxiter, nskipprint=nskipprint, verbose=verbose) end_time = time() # Save the time and solution times[d-1] = end_time - start_time sols[d-1] = vp # Simulate and compute EE ks, zs = simulate(ncgm, vp, shocks; capT=capT, nburn=nburn) resids = ee_residuals(ncgm, vp, ks, zs; Qn=10) mean_ees[d-1] = log10.(mean(abs.(resids))) max_ees[d-1] = log10.(maximum(abs, resids)) end return sols, times, mean_ees, max_ees end ``` main (generic function with 3 methods) ```julia Random.seed!(52) shocks = randn(10200) for sol_method in [VFI(), VFI_EGM(), VFI_ECM(), dVFI_ECM(), PFI(), PFI_ECM(), EulEq()] # Make sure everything is compiled main(sol_method, 5, shocks; maxiter=2, verbose=false) # Run for real s_sm, t_sm, mean_eem, max_eem = main(sol_method, 5, shocks; tol=1e-8, verbose=false) println("Solution Method: $sol_method") for (d, t) in zip([2, 3, 4, 5], t_sm) println("\tDegree $d took time $t") println("\tMean & Max EE are" * "$(round(mean_eem[d-1], digits=3)) & $(round(max_eem[d-1], digits=3))") end end ``` Solution Method: VFI() Degree 2 took time 0.8547611236572266 Mean & Max EE are-3.803 & -2.875 Degree 3 took time 0.7150120735168457 Mean & Max EE are-4.914 & -3.487 Degree 4 took time 0.8598308563232422 Mean & Max EE are-5.978 & -4.226 Degree 5 took time 0.7123589515686035 Mean & Max EE are-6.916 & -4.942 Solution Method: VFI_EGM() Degree 2 took time 0.3311178684234619 Mean & Max EE are-3.803 & -2.876 Degree 3 took time 0.24843502044677734 Mean & Max EE are-4.914 & -3.487 Degree 4 took time 0.30118298530578613 Mean & Max EE are-5.978 & -4.226 Degree 5 took time 0.18770384788513184 Mean & Max EE are-6.916 & -4.942 Solution Method: VFI_ECM() Degree 2 took time 0.2970089912414551 Mean & Max EE are-3.803 & -2.875 Degree 3 took time 0.2128901481628418 Mean & Max EE are-4.914 & -3.487 Degree 4 took time 0.25684499740600586 Mean & Max EE are-5.978 & -4.226 Degree 5 took time 0.1400759220123291 Mean & Max EE are-6.916 & -4.942 Solution Method: dVFI_ECM() Degree 2 took time 0.517967939376831 Mean & Max EE are-3.803 & -2.876 Degree 3 took time 0.6294620037078857 Mean & Max EE are-4.914 & -3.487 Degree 4 took time 0.8079090118408203 Mean & Max EE are-5.978 & -4.226 Degree 5 took time 0.8993039131164551 Mean & Max EE are-6.916 & -4.942 Solution Method: PFI() Degree 2 took time 0.30332493782043457 Mean & Max EE are-3.803 & -2.876 Degree 3 took time 0.6854491233825684 Mean & Max EE are-4.914 & -3.487 Degree 4 took time 0.9637911319732666 Mean & Max EE are-5.978 & -4.226 Degree 5 took time 0.7570579051971436 Mean & Max EE are-6.916 & -4.942 Solution Method: PFI_ECM() Degree 2 took time 0.24885082244873047 Mean & Max EE are-3.803 & -2.876 Degree 3 took time 0.19704389572143555 Mean & Max EE are-4.914 & -3.487 Degree 4 took time 0.23227882385253906 Mean & Max EE are-5.978 & -4.226 Degree 5 took time 0.1265571117401123 Mean & Max EE are-6.916 & -4.942 Solution Method: EulEq() Degree 2 took time 0.34078478813171387 Mean & Max EE are-3.803 & -2.876 Degree 3 took time 0.24483489990234375 Mean & Max EE are-4.914 & -3.487 Degree 4 took time 0.27704310417175293 Mean & Max EE are-5.978 & -4.226 Degree 5 took time 0.14841604232788086 Mean & Max EE are-6.916 & -4.942 ```julia ```
lemma real_eq_affinity: "m \<noteq> 0 \<Longrightarrow> y = m * x + c \<longleftrightarrow> inverse m * y + - (c / m) = x" for m :: "'a::linordered_field"
(* Title: HOL/Induct/Comb.thy Author: Lawrence C Paulson Copyright 1996 University of Cambridge *) section \<open>Combinatory Logic example: the Church-Rosser Theorem\<close> theory Comb imports MainRLT begin text \<open> Combinator terms do not have free variables. Example taken from @{cite camilleri92}. \<close> subsection \<open>Definitions\<close> text \<open>Datatype definition of combinators \<open>S\<close> and \<open>K\<close>.\<close> datatype comb = K | S | Ap comb comb (infixl "\<bullet>" 90) text \<open> Inductive definition of contractions, \<open>\<rightarrow>\<^sup>1\<close> and (multi-step) reductions, \<open>\<rightarrow>\<close>. \<close> inductive contract1 :: "[comb,comb] \<Rightarrow> bool" (infixl "\<rightarrow>\<^sup>1" 50) where K: "K\<bullet>x\<bullet>y \<rightarrow>\<^sup>1 x" | S: "S\<bullet>x\<bullet>y\<bullet>z \<rightarrow>\<^sup>1 (x\<bullet>z)\<bullet>(y\<bullet>z)" | Ap1: "x \<rightarrow>\<^sup>1 y \<Longrightarrow> x\<bullet>z \<rightarrow>\<^sup>1 y\<bullet>z" | Ap2: "x \<rightarrow>\<^sup>1 y \<Longrightarrow> z\<bullet>x \<rightarrow>\<^sup>1 z\<bullet>y" abbreviation contract :: "[comb,comb] \<Rightarrow> bool" (infixl "\<rightarrow>" 50) where "contract \<equiv> contract1\<^sup>*\<^sup>*" text \<open> Inductive definition of parallel contractions, \<open>\<Rrightarrow>\<^sup>1\<close> and (multi-step) parallel reductions, \<open>\<Rrightarrow>\<close>. \<close> inductive parcontract1 :: "[comb,comb] \<Rightarrow> bool" (infixl "\<Rrightarrow>\<^sup>1" 50) where refl: "x \<Rrightarrow>\<^sup>1 x" | K: "K\<bullet>x\<bullet>y \<Rrightarrow>\<^sup>1 x" | S: "S\<bullet>x\<bullet>y\<bullet>z \<Rrightarrow>\<^sup>1 (x\<bullet>z)\<bullet>(y\<bullet>z)" | Ap: "\<lbrakk>x \<Rrightarrow>\<^sup>1 y; z \<Rrightarrow>\<^sup>1 w\<rbrakk> \<Longrightarrow> x\<bullet>z \<Rrightarrow>\<^sup>1 y\<bullet>w" abbreviation parcontract :: "[comb,comb] \<Rightarrow> bool" (infixl "\<Rrightarrow>" 50) where "parcontract \<equiv> parcontract1\<^sup>*\<^sup>*" text \<open> Misc definitions. \<close> definition I :: comb where "I \<equiv> S\<bullet>K\<bullet>K" definition diamond :: "([comb,comb] \<Rightarrow> bool) \<Rightarrow> bool" where \<comment> \<open>confluence; Lambda/Commutation treats this more abstractly\<close> "diamond r \<equiv> \<forall>x y. r x y \<longrightarrow> (\<forall>y'. r x y' \<longrightarrow> (\<exists>z. r y z \<and> r y' z))" subsection \<open>Reflexive/Transitive closure preserves Church-Rosser property\<close> text\<open>Remark: So does the Transitive closure, with a similar proof\<close> text\<open>Strip lemma. The induction hypothesis covers all but the last diamond of the strip.\<close> lemma strip_lemma [rule_format]: assumes "diamond r" and r: "r\<^sup>*\<^sup>* x y" "r x y'" shows "\<exists>z. r\<^sup>*\<^sup>* y' z \<and> r y z" using r proof (induction rule: rtranclp_induct) case base then show ?case by blast next case (step y z) then show ?case using \<open>diamond r\<close> unfolding diamond_def by (metis rtranclp.rtrancl_into_rtrancl) qed proposition diamond_rtrancl: assumes "diamond r" shows "diamond(r\<^sup>*\<^sup>*)" unfolding diamond_def proof (intro strip) fix x y y' assume "r\<^sup>*\<^sup>* x y" "r\<^sup>*\<^sup>* x y'" then show "\<exists>z. r\<^sup>*\<^sup>* y z \<and> r\<^sup>*\<^sup>* y' z" proof (induction rule: rtranclp_induct) case base then show ?case by blast next case (step y z) then show ?case by (meson assms strip_lemma rtranclp.rtrancl_into_rtrancl) qed qed subsection \<open>Non-contraction results\<close> text \<open>Derive a case for each combinator constructor.\<close> inductive_cases K_contractE [elim!]: "K \<rightarrow>\<^sup>1 r" and S_contractE [elim!]: "S \<rightarrow>\<^sup>1 r" and Ap_contractE [elim!]: "p\<bullet>q \<rightarrow>\<^sup>1 r" declare contract1.K [intro!] contract1.S [intro!] declare contract1.Ap1 [intro] contract1.Ap2 [intro] lemma I_contract_E [iff]: "\<not> I \<rightarrow>\<^sup>1 z" unfolding I_def by blast lemma K1_contractD [elim!]: "K\<bullet>x \<rightarrow>\<^sup>1 z \<Longrightarrow> (\<exists>x'. z = K\<bullet>x' \<and> x \<rightarrow>\<^sup>1 x')" by blast lemma Ap_reduce1 [intro]: "x \<rightarrow> y \<Longrightarrow> x\<bullet>z \<rightarrow> y\<bullet>z" by (induction rule: rtranclp_induct; blast intro: rtranclp_trans) lemma Ap_reduce2 [intro]: "x \<rightarrow> y \<Longrightarrow> z\<bullet>x \<rightarrow> z\<bullet>y" by (induction rule: rtranclp_induct; blast intro: rtranclp_trans) text \<open>Counterexample to the diamond property for \<^term>\<open>x \<rightarrow>\<^sup>1 y\<close>\<close> lemma not_diamond_contract: "\<not> diamond(contract1)" unfolding diamond_def by (metis S_contractE contract1.K) subsection \<open>Results about Parallel Contraction\<close> text \<open>Derive a case for each combinator constructor.\<close> inductive_cases K_parcontractE [elim!]: "K \<Rrightarrow>\<^sup>1 r" and S_parcontractE [elim!]: "S \<Rrightarrow>\<^sup>1 r" and Ap_parcontractE [elim!]: "p\<bullet>q \<Rrightarrow>\<^sup>1 r" declare parcontract1.intros [intro] subsection \<open>Basic properties of parallel contraction\<close> text\<open>The rules below are not essential but make proofs much faster\<close> lemma K1_parcontractD [dest!]: "K\<bullet>x \<Rrightarrow>\<^sup>1 z \<Longrightarrow> (\<exists>x'. z = K\<bullet>x' \<and> x \<Rrightarrow>\<^sup>1 x')" by blast lemma S1_parcontractD [dest!]: "S\<bullet>x \<Rrightarrow>\<^sup>1 z \<Longrightarrow> (\<exists>x'. z = S\<bullet>x' \<and> x \<Rrightarrow>\<^sup>1 x')" by blast lemma S2_parcontractD [dest!]: "S\<bullet>x\<bullet>y \<Rrightarrow>\<^sup>1 z \<Longrightarrow> (\<exists>x' y'. z = S\<bullet>x'\<bullet>y' \<and> x \<Rrightarrow>\<^sup>1 x' \<and> y \<Rrightarrow>\<^sup>1 y')" by blast text\<open>Church-Rosser property for parallel contraction\<close> proposition diamond_parcontract: "diamond parcontract1" proof - have "(\<exists>z. w \<Rrightarrow>\<^sup>1 z \<and> y' \<Rrightarrow>\<^sup>1 z)" if "y \<Rrightarrow>\<^sup>1 w" "y \<Rrightarrow>\<^sup>1 y'" for w y y' using that by (induction arbitrary: y' rule: parcontract1.induct) fast+ then show ?thesis by (auto simp: diamond_def) qed subsection \<open>Equivalence of \<^prop>\<open>p \<rightarrow> q\<close> and \<^prop>\<open>p \<Rrightarrow> q\<close>.\<close> lemma contract_imp_parcontract: "x \<rightarrow>\<^sup>1 y \<Longrightarrow> x \<Rrightarrow>\<^sup>1 y" by (induction rule: contract1.induct; blast) text\<open>Reductions: simply throw together reflexivity, transitivity and the one-step reductions\<close> proposition reduce_I: "I\<bullet>x \<rightarrow> x" unfolding I_def by (meson contract1.K contract1.S r_into_rtranclp rtranclp.rtrancl_into_rtrancl) lemma parcontract_imp_reduce: "x \<Rrightarrow>\<^sup>1 y \<Longrightarrow> x \<rightarrow> y" proof (induction rule: parcontract1.induct) case (Ap x y z w) then show ?case by (meson Ap_reduce1 Ap_reduce2 rtranclp_trans) qed auto lemma reduce_eq_parreduce: "x \<rightarrow> y \<longleftrightarrow> x \<Rrightarrow> y" by (metis contract_imp_parcontract parcontract_imp_reduce predicate2I rtranclp_subset) theorem diamond_reduce: "diamond(contract)" using diamond_parcontract diamond_rtrancl reduce_eq_parreduce by presburger end
Formal statement is: lemma Inf_lim: fixes a :: "'a::{complete_linorder,linorder_topology}" assumes "\<And>n. b n \<in> s" and "b \<longlonglongrightarrow> a" shows "Inf s \<le> a" Informal statement is: If $b_n$ is a sequence in $s$ that converges to $a$, then $a$ is greater than or equal to the infimum of $s$.
! ! Parallel Sparse BLAS version 3.5 ! (C) Copyright 2006-2018 ! Salvatore Filippone ! Alfredo Buttari ! ! Redistribution and use in source and binary forms, with or without ! modification, are permitted provided that the following conditions ! are met: ! 1. Redistributions of source code must retain the above copyright ! notice, this list of conditions and the following disclaimer. ! 2. 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. ! 3. The name of the PSBLAS group or the names of its contributors may ! not be used to endorse or promote products derived from this ! software without specific 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 PSBLAS GROUP OR ITS 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. ! ! ! ! package: psb_s_csr_mat_mod ! ! This module contains the definition of the psb_s_csr_sparse_mat type ! which implements an actual storage format (the CSR in this case) for ! a sparse matrix as well as the related methods (those who are ! specific to the type and could not be defined higher in the ! hierarchy). We are at the bottom level of the inheritance chain. ! ! Please refere to psb_s_base_mat_mod for a detailed description ! of the various methods, and to psb_s_csr_impl for implementation details. ! module psb_s_csr_mat_mod use psb_s_base_mat_mod !> \namespace psb_base_mod \class psb_s_csr_sparse_mat !! \extends psb_s_base_mat_mod::psb_s_base_sparse_mat !! !! psb_s_csr_sparse_mat type and the related methods. !! This is a very common storage type, and is the default for assembled !! matrices in our library type, extends(psb_s_base_sparse_mat) :: psb_s_csr_sparse_mat !> Pointers to beginning of rows in JA and VAL. integer(psb_ipk_), allocatable :: irp(:) !> Column indices. integer(psb_ipk_), allocatable :: ja(:) !> Coefficient values. real(psb_spk_), allocatable :: val(:) contains procedure, pass(a) :: is_by_rows => s_csr_is_by_rows procedure, pass(a) :: get_size => s_csr_get_size procedure, pass(a) :: get_nzeros => s_csr_get_nzeros procedure, nopass :: get_fmt => s_csr_get_fmt procedure, pass(a) :: sizeof => s_csr_sizeof procedure, pass(a) :: csmm => psb_s_csr_csmm procedure, pass(a) :: csmv => psb_s_csr_csmv procedure, pass(a) :: inner_cssm => psb_s_csr_cssm procedure, pass(a) :: inner_cssv => psb_s_csr_cssv procedure, pass(a) :: scals => psb_s_csr_scals procedure, pass(a) :: scalv => psb_s_csr_scal procedure, pass(a) :: maxval => psb_s_csr_maxval procedure, pass(a) :: spnmi => psb_s_csr_csnmi procedure, pass(a) :: rowsum => psb_s_csr_rowsum procedure, pass(a) :: arwsum => psb_s_csr_arwsum procedure, pass(a) :: colsum => psb_s_csr_colsum procedure, pass(a) :: aclsum => psb_s_csr_aclsum procedure, pass(a) :: reallocate_nz => psb_s_csr_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_s_csr_allocate_mnnz procedure, pass(a) :: tril => psb_s_csr_tril procedure, pass(a) :: triu => psb_s_csr_triu procedure, pass(a) :: cp_to_coo => psb_s_cp_csr_to_coo procedure, pass(a) :: cp_from_coo => psb_s_cp_csr_from_coo procedure, pass(a) :: cp_to_fmt => psb_s_cp_csr_to_fmt procedure, pass(a) :: cp_from_fmt => psb_s_cp_csr_from_fmt procedure, pass(a) :: mv_to_coo => psb_s_mv_csr_to_coo procedure, pass(a) :: mv_from_coo => psb_s_mv_csr_from_coo procedure, pass(a) :: mv_to_fmt => psb_s_mv_csr_to_fmt procedure, pass(a) :: mv_from_fmt => psb_s_mv_csr_from_fmt procedure, pass(a) :: csput_a => psb_s_csr_csput_a procedure, pass(a) :: get_diag => psb_s_csr_get_diag procedure, pass(a) :: csgetptn => psb_s_csr_csgetptn procedure, pass(a) :: csgetrow => psb_s_csr_csgetrow procedure, pass(a) :: get_nz_row => s_csr_get_nz_row procedure, pass(a) :: reinit => psb_s_csr_reinit procedure, pass(a) :: trim => psb_s_csr_trim procedure, pass(a) :: print => psb_s_csr_print procedure, pass(a) :: free => s_csr_free procedure, pass(a) :: mold => psb_s_csr_mold end type psb_s_csr_sparse_mat private :: s_csr_get_nzeros, s_csr_free, s_csr_get_fmt, & & s_csr_get_size, s_csr_sizeof, s_csr_get_nz_row, & & s_csr_is_by_rows !> \memberof psb_s_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_reallocate_nz interface subroutine psb_s_csr_reallocate_nz(nz,a) import integer(psb_ipk_), intent(in) :: nz class(psb_s_csr_sparse_mat), intent(inout) :: a end subroutine psb_s_csr_reallocate_nz end interface !> \memberof psb_s_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_reinit interface subroutine psb_s_csr_reinit(a,clear) import class(psb_s_csr_sparse_mat), intent(inout) :: a logical, intent(in), optional :: clear end subroutine psb_s_csr_reinit end interface !> \memberof psb_s_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_trim interface subroutine psb_s_csr_trim(a) import class(psb_s_csr_sparse_mat), intent(inout) :: a end subroutine psb_s_csr_trim end interface !> \memberof psb_s_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_mold interface subroutine psb_s_csr_mold(a,b,info) import class(psb_s_csr_sparse_mat), intent(in) :: a class(psb_s_base_sparse_mat), intent(inout), allocatable :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_s_csr_mold end interface !> \memberof psb_s_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_allocate_mnnz interface subroutine psb_s_csr_allocate_mnnz(m,n,a,nz) import integer(psb_ipk_), intent(in) :: m,n class(psb_s_csr_sparse_mat), intent(inout) :: a integer(psb_ipk_), intent(in), optional :: nz end subroutine psb_s_csr_allocate_mnnz end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_print interface subroutine psb_s_csr_print(iout,a,iv,head,ivr,ivc) import integer(psb_ipk_), intent(in) :: iout class(psb_s_csr_sparse_mat), intent(in) :: a integer(psb_ipk_), intent(in), optional :: iv(:) character(len=*), optional :: head integer(psb_ipk_), intent(in), optional :: ivr(:), ivc(:) end subroutine psb_s_csr_print end interface ! !> Function tril: !! \memberof psb_s_base_sparse_mat !! \brief Copy the lower triangle, i.e. all entries !! A(I,J) such that J-I <= DIAG !! default value is DIAG=0, i.e. lower triangle up to !! the main diagonal. !! DIAG=-1 means copy the strictly lower triangle !! DIAG= 1 means copy the lower triangle plus the first diagonal !! of the upper triangle. !! Moreover, apply a clipping by copying entries A(I,J) only if !! IMIN<=I<=IMAX !! JMIN<=J<=JMAX !! !! \param l the output (sub)matrix !! \param info return code !! \param diag [0] the last diagonal (J-I) to be considered. !! \param imin [1] the minimum row index we are interested in !! \param imax [a\%get_nrows()] the minimum row index we are interested in !! \param jmin [1] minimum col index !! \param jmax [a\%get_ncols()] maximum col index !! \param iren(:) [none] an array to return renumbered indices (iren(ia(:)),iren(ja(:)) !! \param rscale [false] map [min(ia(:)):max(ia(:))] onto [1:max(ia(:))-min(ia(:))+1] !! \param cscale [false] map [min(ja(:)):max(ja(:))] onto [1:max(ja(:))-min(ja(:))+1] !! ( iren cannot be specified with rscale/cscale) !! \param append [false] append to ia,ja !! \param nzin [none] if append, then first new entry should go in entry nzin+1 !! \param u [none] copy of the complementary triangle !! ! interface subroutine psb_s_csr_tril(a,l,info,diag,imin,imax,& & jmin,jmax,rscale,cscale,u) import class(psb_s_csr_sparse_mat), intent(in) :: a class(psb_s_coo_sparse_mat), intent(out) :: l integer(psb_ipk_),intent(out) :: info integer(psb_ipk_), intent(in), optional :: diag,imin,imax,jmin,jmax logical, intent(in), optional :: rscale,cscale class(psb_s_coo_sparse_mat), optional, intent(out) :: u end subroutine psb_s_csr_tril end interface ! !> Function triu: !! \memberof psb_s_csr_sparse_mat !! \brief Copy the upper triangle, i.e. all entries !! A(I,J) such that DIAG <= J-I !! default value is DIAG=0, i.e. upper triangle from !! the main diagonal up. !! DIAG= 1 means copy the strictly upper triangle !! DIAG=-1 means copy the upper triangle plus the first diagonal !! of the lower triangle. !! Moreover, apply a clipping by copying entries A(I,J) only if !! IMIN<=I<=IMAX !! JMIN<=J<=JMAX !! Optionally copies the lower triangle at the same time !! !! \param u the output (sub)matrix !! \param info return code !! \param diag [0] the last diagonal (J-I) to be considered. !! \param imin [1] the minimum row index we are interested in !! \param imax [a\%get_nrows()] the minimum row index we are interested in !! \param jmin [1] minimum col index !! \param jmax [a\%get_ncols()] maximum col index !! \param iren(:) [none] an array to return renumbered indices (iren(ia(:)),iren(ja(:)) !! \param rscale [false] map [min(ia(:)):max(ia(:))] onto [1:max(ia(:))-min(ia(:))+1] !! \param cscale [false] map [min(ja(:)):max(ja(:))] onto [1:max(ja(:))-min(ja(:))+1] !! ( iren cannot be specified with rscale/cscale) !! \param append [false] append to ia,ja !! \param nzin [none] if append, then first new entry should go in entry nzin+1 !! \param l [none] copy of the complementary triangle !! ! interface subroutine psb_s_csr_triu(a,u,info,diag,imin,imax,& & jmin,jmax,rscale,cscale,l) import class(psb_s_csr_sparse_mat), intent(in) :: a class(psb_s_coo_sparse_mat), intent(out) :: u integer(psb_ipk_),intent(out) :: info integer(psb_ipk_), intent(in), optional :: diag,imin,imax,jmin,jmax logical, intent(in), optional :: rscale,cscale class(psb_s_coo_sparse_mat), optional, intent(out) :: l end subroutine psb_s_csr_triu end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_cp_to_coo interface subroutine psb_s_cp_csr_to_coo(a,b,info) import class(psb_s_csr_sparse_mat), intent(in) :: a class(psb_s_coo_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_s_cp_csr_to_coo end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_cp_from_coo interface subroutine psb_s_cp_csr_from_coo(a,b,info) import class(psb_s_csr_sparse_mat), intent(inout) :: a class(psb_s_coo_sparse_mat), intent(in) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_s_cp_csr_from_coo end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_cp_to_fmt interface subroutine psb_s_cp_csr_to_fmt(a,b,info) import class(psb_s_csr_sparse_mat), intent(in) :: a class(psb_s_base_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_s_cp_csr_to_fmt end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_cp_from_fmt interface subroutine psb_s_cp_csr_from_fmt(a,b,info) import class(psb_s_csr_sparse_mat), intent(inout) :: a class(psb_s_base_sparse_mat), intent(in) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_s_cp_csr_from_fmt end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_mv_to_coo interface subroutine psb_s_mv_csr_to_coo(a,b,info) import class(psb_s_csr_sparse_mat), intent(inout) :: a class(psb_s_coo_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_s_mv_csr_to_coo end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_mv_from_coo interface subroutine psb_s_mv_csr_from_coo(a,b,info) import class(psb_s_csr_sparse_mat), intent(inout) :: a class(psb_s_coo_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_s_mv_csr_from_coo end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_mv_to_fmt interface subroutine psb_s_mv_csr_to_fmt(a,b,info) import class(psb_s_csr_sparse_mat), intent(inout) :: a class(psb_s_base_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_s_mv_csr_to_fmt end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_mv_from_fmt interface subroutine psb_s_mv_csr_from_fmt(a,b,info) import class(psb_s_csr_sparse_mat), intent(inout) :: a class(psb_s_base_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_s_mv_csr_from_fmt end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_cp_from interface subroutine psb_s_csr_cp_from(a,b) import class(psb_s_csr_sparse_mat), intent(inout) :: a type(psb_s_csr_sparse_mat), intent(in) :: b end subroutine psb_s_csr_cp_from end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_mv_from interface subroutine psb_s_csr_mv_from(a,b) import class(psb_s_csr_sparse_mat), intent(inout) :: a type(psb_s_csr_sparse_mat), intent(inout) :: b end subroutine psb_s_csr_mv_from end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_csput_a interface subroutine psb_s_csr_csput_a(nz,ia,ja,val,a,imin,imax,jmin,jmax,info) import class(psb_s_csr_sparse_mat), intent(inout) :: a real(psb_spk_), intent(in) :: val(:) integer(psb_ipk_), intent(in) :: nz,ia(:), ja(:),& & imin,imax,jmin,jmax integer(psb_ipk_), intent(out) :: info end subroutine psb_s_csr_csput_a end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_base_mat_mod::psb_base_csgetptn interface subroutine psb_s_csr_csgetptn(imin,imax,a,nz,ia,ja,info,& & jmin,jmax,iren,append,nzin,rscale,cscale) import class(psb_s_csr_sparse_mat), intent(in) :: a integer(psb_ipk_), intent(in) :: imin,imax integer(psb_ipk_), intent(out) :: nz integer(psb_ipk_), allocatable, intent(inout) :: ia(:), ja(:) integer(psb_ipk_),intent(out) :: info logical, intent(in), optional :: append integer(psb_ipk_), intent(in), optional :: iren(:) integer(psb_ipk_), intent(in), optional :: jmin,jmax, nzin logical, intent(in), optional :: rscale,cscale end subroutine psb_s_csr_csgetptn end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_csgetrow interface subroutine psb_s_csr_csgetrow(imin,imax,a,nz,ia,ja,val,info,& & jmin,jmax,iren,append,nzin,rscale,cscale,chksz) import class(psb_s_csr_sparse_mat), intent(in) :: a integer(psb_ipk_), intent(in) :: imin,imax integer(psb_ipk_), intent(out) :: nz integer(psb_ipk_), allocatable, intent(inout) :: ia(:), ja(:) real(psb_spk_), allocatable, intent(inout) :: val(:) integer(psb_ipk_),intent(out) :: info logical, intent(in), optional :: append integer(psb_ipk_), intent(in), optional :: iren(:) integer(psb_ipk_), intent(in), optional :: jmin,jmax, nzin logical, intent(in), optional :: rscale,cscale,chksz end subroutine psb_s_csr_csgetrow end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_cssv interface subroutine psb_s_csr_cssv(alpha,a,x,beta,y,info,trans) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(in) :: alpha, beta, x(:) real(psb_spk_), intent(inout) :: y(:) integer(psb_ipk_), intent(out) :: info character, optional, intent(in) :: trans end subroutine psb_s_csr_cssv end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_cssm interface subroutine psb_s_csr_cssm(alpha,a,x,beta,y,info,trans) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(in) :: alpha, beta, x(:,:) real(psb_spk_), intent(inout) :: y(:,:) integer(psb_ipk_), intent(out) :: info character, optional, intent(in) :: trans end subroutine psb_s_csr_cssm end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_csmv interface subroutine psb_s_csr_csmv(alpha,a,x,beta,y,info,trans) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(in) :: alpha, beta, x(:) real(psb_spk_), intent(inout) :: y(:) integer(psb_ipk_), intent(out) :: info character, optional, intent(in) :: trans end subroutine psb_s_csr_csmv end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_csmm interface subroutine psb_s_csr_csmm(alpha,a,x,beta,y,info,trans) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(in) :: alpha, beta, x(:,:) real(psb_spk_), intent(inout) :: y(:,:) integer(psb_ipk_), intent(out) :: info character, optional, intent(in) :: trans end subroutine psb_s_csr_csmm end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_maxval interface function psb_s_csr_maxval(a) result(res) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_) :: res end function psb_s_csr_maxval end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_csnmi interface function psb_s_csr_csnmi(a) result(res) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_) :: res end function psb_s_csr_csnmi end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_rowsum interface subroutine psb_s_csr_rowsum(d,a) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) end subroutine psb_s_csr_rowsum end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_arwsum interface subroutine psb_s_csr_arwsum(d,a) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) end subroutine psb_s_csr_arwsum end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_colsum interface subroutine psb_s_csr_colsum(d,a) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) end subroutine psb_s_csr_colsum end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_aclsum interface subroutine psb_s_csr_aclsum(d,a) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) end subroutine psb_s_csr_aclsum end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_get_diag interface subroutine psb_s_csr_get_diag(a,d,info) import class(psb_s_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) integer(psb_ipk_), intent(out) :: info end subroutine psb_s_csr_get_diag end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_scal interface subroutine psb_s_csr_scal(d,a,info,side) import class(psb_s_csr_sparse_mat), intent(inout) :: a real(psb_spk_), intent(in) :: d(:) integer(psb_ipk_), intent(out) :: info character, intent(in), optional :: side end subroutine psb_s_csr_scal end interface !> \memberof psb_s_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_s_base_scals interface subroutine psb_s_csr_scals(d,a,info) import class(psb_s_csr_sparse_mat), intent(inout) :: a real(psb_spk_), intent(in) :: d integer(psb_ipk_), intent(out) :: info end subroutine psb_s_csr_scals end interface !> \namespace psb_base_mod \class psb_ls_csr_sparse_mat !! \extends psb_ls_base_mat_mod::psb_ls_base_sparse_mat !! !! psb_ls_csr_sparse_mat type and the related methods. !! This is a very common storage type, and is the default for assembled !! matrices in our library type, extends(psb_ls_base_sparse_mat) :: psb_ls_csr_sparse_mat !> Pointers to beginning of rows in JA and VAL. integer(psb_lpk_), allocatable :: irp(:) !> Column indices. integer(psb_lpk_), allocatable :: ja(:) !> Coefficient values. real(psb_spk_), allocatable :: val(:) contains procedure, pass(a) :: is_by_rows => ls_csr_is_by_rows procedure, pass(a) :: get_size => ls_csr_get_size procedure, pass(a) :: get_nzeros => ls_csr_get_nzeros procedure, nopass :: get_fmt => ls_csr_get_fmt procedure, pass(a) :: sizeof => ls_csr_sizeof procedure, pass(a) :: reallocate_nz => psb_ls_csr_reallocate_nz procedure, pass(a) :: allocate_mnnz => psb_ls_csr_allocate_mnnz procedure, pass(a) :: tril => psb_ls_csr_tril procedure, pass(a) :: triu => psb_ls_csr_triu procedure, pass(a) :: cp_to_coo => psb_ls_cp_csr_to_coo procedure, pass(a) :: cp_from_coo => psb_ls_cp_csr_from_coo procedure, pass(a) :: cp_to_fmt => psb_ls_cp_csr_to_fmt procedure, pass(a) :: cp_from_fmt => psb_ls_cp_csr_from_fmt procedure, pass(a) :: mv_to_coo => psb_ls_mv_csr_to_coo procedure, pass(a) :: mv_from_coo => psb_ls_mv_csr_from_coo procedure, pass(a) :: mv_to_fmt => psb_ls_mv_csr_to_fmt procedure, pass(a) :: mv_from_fmt => psb_ls_mv_csr_from_fmt procedure, pass(a) :: csput_a => psb_ls_csr_csput_a procedure, pass(a) :: get_diag => psb_ls_csr_get_diag procedure, pass(a) :: csgetptn => psb_ls_csr_csgetptn procedure, pass(a) :: csgetrow => psb_ls_csr_csgetrow procedure, pass(a) :: get_nz_row => ls_csr_get_nz_row procedure, pass(a) :: reinit => psb_ls_csr_reinit procedure, pass(a) :: trim => psb_ls_csr_trim procedure, pass(a) :: print => psb_ls_csr_print procedure, pass(a) :: free => ls_csr_free procedure, pass(a) :: mold => psb_ls_csr_mold procedure, pass(a) :: scals => psb_ls_csr_scals procedure, pass(a) :: scalv => psb_ls_csr_scal procedure, pass(a) :: maxval => psb_ls_csr_maxval procedure, pass(a) :: spnmi => psb_ls_csr_csnmi procedure, pass(a) :: rowsum => psb_ls_csr_rowsum procedure, pass(a) :: arwsum => psb_ls_csr_arwsum procedure, pass(a) :: colsum => psb_ls_csr_colsum procedure, pass(a) :: aclsum => psb_ls_csr_aclsum end type psb_ls_csr_sparse_mat private :: ls_csr_get_nzeros, ls_csr_free, ls_csr_get_fmt, & & ls_csr_get_size, ls_csr_sizeof, ls_csr_get_nz_row, & & ls_csr_is_by_rows !> \memberof psb_ls_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_reallocate_nz interface subroutine psb_ls_csr_reallocate_nz(nz,a) import integer(psb_lpk_), intent(in) :: nz class(psb_ls_csr_sparse_mat), intent(inout) :: a end subroutine psb_ls_csr_reallocate_nz end interface !> \memberof psb_ls_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_reinit interface subroutine psb_ls_csr_reinit(a,clear) import class(psb_ls_csr_sparse_mat), intent(inout) :: a logical, intent(in), optional :: clear end subroutine psb_ls_csr_reinit end interface !> \memberof psb_ls_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_trim interface subroutine psb_ls_csr_trim(a) import class(psb_ls_csr_sparse_mat), intent(inout) :: a end subroutine psb_ls_csr_trim end interface !> \memberof psb_ls_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_mold interface subroutine psb_ls_csr_mold(a,b,info) import class(psb_ls_csr_sparse_mat), intent(in) :: a class(psb_ls_base_sparse_mat), intent(inout), allocatable :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_csr_mold end interface !> \memberof psb_ls_csr_sparse_mat !| \see psb_base_mat_mod::psb_base_allocate_mnnz interface subroutine psb_ls_csr_allocate_mnnz(m,n,a,nz) import integer(psb_lpk_), intent(in) :: m,n class(psb_ls_csr_sparse_mat), intent(inout) :: a integer(psb_lpk_), intent(in), optional :: nz end subroutine psb_ls_csr_allocate_mnnz end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_print interface subroutine psb_ls_csr_print(iout,a,iv,head,ivr,ivc) import integer(psb_ipk_), intent(in) :: iout class(psb_ls_csr_sparse_mat), intent(in) :: a integer(psb_lpk_), intent(in), optional :: iv(:) character(len=*), optional :: head integer(psb_lpk_), intent(in), optional :: ivr(:), ivc(:) end subroutine psb_ls_csr_print end interface ! !> Function tril: !! \memberof psb_s_base_sparse_mat !! \brief Copy the lower triangle, i.e. all entries !! A(I,J) such that J-I <= DIAG !! default value is DIAG=0, i.e. lower triangle up to !! the main diagonal. !! DIAG=-1 means copy the strictly lower triangle !! DIAG= 1 means copy the lower triangle plus the first diagonal !! of the upper triangle. !! Moreover, apply a clipping by copying entries A(I,J) only if !! IMIN<=I<=IMAX !! JMIN<=J<=JMAX !! !! \param l the output (sub)matrix !! \param info return code !! \param diag [0] the last diagonal (J-I) to be considered. !! \param imin [1] the minimum row index we are interested in !! \param imax [a\%get_nrows()] the minimum row index we are interested in !! \param jmin [1] minimum col index !! \param jmax [a\%get_ncols()] maximum col index !! \param iren(:) [none] an array to return renumbered indices (iren(ia(:)),iren(ja(:)) !! \param rscale [false] map [min(ia(:)):max(ia(:))] onto [1:max(ia(:))-min(ia(:))+1] !! \param cscale [false] map [min(ja(:)):max(ja(:))] onto [1:max(ja(:))-min(ja(:))+1] !! ( iren cannot be specified with rscale/cscale) !! \param append [false] append to ia,ja !! \param nzin [none] if append, then first new entry should go in entry nzin+1 !! \param u [none] copy of the complementary triangle !! ! interface subroutine psb_ls_csr_tril(a,l,info,diag,imin,imax,& & jmin,jmax,rscale,cscale,u) import class(psb_ls_csr_sparse_mat), intent(in) :: a class(psb_ls_coo_sparse_mat), intent(out) :: l integer(psb_ipk_),intent(out) :: info integer(psb_lpk_), intent(in), optional :: diag,imin,imax,jmin,jmax logical, intent(in), optional :: rscale,cscale class(psb_ls_coo_sparse_mat), optional, intent(out) :: u end subroutine psb_ls_csr_tril end interface ! !> Function triu: !! \memberof psb_s_csr_sparse_mat !! \brief Copy the upper triangle, i.e. all entries !! A(I,J) such that DIAG <= J-I !! default value is DIAG=0, i.e. upper triangle from !! the main diagonal up. !! DIAG= 1 means copy the strictly upper triangle !! DIAG=-1 means copy the upper triangle plus the first diagonal !! of the lower triangle. !! Moreover, apply a clipping by copying entries A(I,J) only if !! IMIN<=I<=IMAX !! JMIN<=J<=JMAX !! Optionally copies the lower triangle at the same time !! !! \param u the output (sub)matrix !! \param info return code !! \param diag [0] the last diagonal (J-I) to be considered. !! \param imin [1] the minimum row index we are interested in !! \param imax [a\%get_nrows()] the minimum row index we are interested in !! \param jmin [1] minimum col index !! \param jmax [a\%get_ncols()] maximum col index !! \param iren(:) [none] an array to return renumbered indices (iren(ia(:)),iren(ja(:)) !! \param rscale [false] map [min(ia(:)):max(ia(:))] onto [1:max(ia(:))-min(ia(:))+1] !! \param cscale [false] map [min(ja(:)):max(ja(:))] onto [1:max(ja(:))-min(ja(:))+1] !! ( iren cannot be specified with rscale/cscale) !! \param append [false] append to ia,ja !! \param nzin [none] if append, then first new entry should go in entry nzin+1 !! \param l [none] copy of the complementary triangle !! ! interface subroutine psb_ls_csr_triu(a,u,info,diag,imin,imax,& & jmin,jmax,rscale,cscale,l) import class(psb_ls_csr_sparse_mat), intent(in) :: a class(psb_ls_coo_sparse_mat), intent(out) :: u integer(psb_ipk_),intent(out) :: info integer(psb_lpk_), intent(in), optional :: diag,imin,imax,jmin,jmax logical, intent(in), optional :: rscale,cscale class(psb_ls_coo_sparse_mat), optional, intent(out) :: l end subroutine psb_ls_csr_triu end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_cp_to_coo interface subroutine psb_ls_cp_csr_to_coo(a,b,info) import class(psb_ls_csr_sparse_mat), intent(in) :: a class(psb_ls_coo_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_cp_csr_to_coo end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_cp_from_coo interface subroutine psb_ls_cp_csr_from_coo(a,b,info) import class(psb_ls_csr_sparse_mat), intent(inout) :: a class(psb_ls_coo_sparse_mat), intent(in) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_cp_csr_from_coo end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_cp_to_fmt interface subroutine psb_ls_cp_csr_to_fmt(a,b,info) import class(psb_ls_csr_sparse_mat), intent(in) :: a class(psb_ls_base_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_cp_csr_to_fmt end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_cp_from_fmt interface subroutine psb_ls_cp_csr_from_fmt(a,b,info) import class(psb_ls_csr_sparse_mat), intent(inout) :: a class(psb_ls_base_sparse_mat), intent(in) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_cp_csr_from_fmt end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_mv_to_coo interface subroutine psb_ls_mv_csr_to_coo(a,b,info) import class(psb_ls_csr_sparse_mat), intent(inout) :: a class(psb_ls_coo_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_mv_csr_to_coo end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_mv_from_coo interface subroutine psb_ls_mv_csr_from_coo(a,b,info) import class(psb_ls_csr_sparse_mat), intent(inout) :: a class(psb_ls_coo_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_mv_csr_from_coo end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_mv_to_fmt interface subroutine psb_ls_mv_csr_to_fmt(a,b,info) import class(psb_ls_csr_sparse_mat), intent(inout) :: a class(psb_ls_base_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_mv_csr_to_fmt end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_mv_from_fmt interface subroutine psb_ls_mv_csr_from_fmt(a,b,info) import class(psb_ls_csr_sparse_mat), intent(inout) :: a class(psb_ls_base_sparse_mat), intent(inout) :: b integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_mv_csr_from_fmt end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_cp_from interface subroutine psb_ls_csr_cp_from(a,b) import class(psb_ls_csr_sparse_mat), intent(inout) :: a type(psb_ls_csr_sparse_mat), intent(in) :: b end subroutine psb_ls_csr_cp_from end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_mv_from interface subroutine psb_ls_csr_mv_from(a,b) import class(psb_ls_csr_sparse_mat), intent(inout) :: a type(psb_ls_csr_sparse_mat), intent(inout) :: b end subroutine psb_ls_csr_mv_from end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_csput_a interface subroutine psb_ls_csr_csput_a(nz,ia,ja,val,a,imin,imax,jmin,jmax,info) import class(psb_ls_csr_sparse_mat), intent(inout) :: a real(psb_spk_), intent(in) :: val(:) integer(psb_lpk_), intent(in) :: nz,ia(:), ja(:),& & imin,imax,jmin,jmax integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_csr_csput_a end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_base_mat_mod::psb_base_csgetptn interface subroutine psb_ls_csr_csgetptn(imin,imax,a,nz,ia,ja,info,& & jmin,jmax,iren,append,nzin,rscale,cscale) import class(psb_ls_csr_sparse_mat), intent(in) :: a integer(psb_lpk_), intent(in) :: imin,imax integer(psb_lpk_), intent(out) :: nz integer(psb_lpk_), allocatable, intent(inout) :: ia(:), ja(:) integer(psb_ipk_),intent(out) :: info logical, intent(in), optional :: append integer(psb_lpk_), intent(in), optional :: iren(:) integer(psb_lpk_), intent(in), optional :: jmin,jmax, nzin logical, intent(in), optional :: rscale,cscale end subroutine psb_ls_csr_csgetptn end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_csgetrow interface subroutine psb_ls_csr_csgetrow(imin,imax,a,nz,ia,ja,val,info,& & jmin,jmax,iren,append,nzin,rscale,cscale) import class(psb_ls_csr_sparse_mat), intent(in) :: a integer(psb_lpk_), intent(in) :: imin,imax integer(psb_lpk_), intent(out) :: nz integer(psb_lpk_), allocatable, intent(inout) :: ia(:), ja(:) real(psb_spk_), allocatable, intent(inout) :: val(:) integer(psb_ipk_),intent(out) :: info logical, intent(in), optional :: append integer(psb_lpk_), intent(in), optional :: iren(:) integer(psb_lpk_), intent(in), optional :: jmin,jmax, nzin logical, intent(in), optional :: rscale,cscale end subroutine psb_ls_csr_csgetrow end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_get_diag interface subroutine psb_ls_csr_get_diag(a,d,info) import class(psb_ls_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_csr_get_diag end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_scal interface subroutine psb_ls_csr_scal(d,a,info,side) import class(psb_ls_csr_sparse_mat), intent(inout) :: a real(psb_spk_), intent(in) :: d(:) integer(psb_ipk_), intent(out) :: info character, intent(in), optional :: side end subroutine psb_ls_csr_scal end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_ls_base_mat_mod::psb_ls_base_scals interface subroutine psb_ls_csr_scals(d,a,info) import class(psb_ls_csr_sparse_mat), intent(inout) :: a real(psb_spk_), intent(in) :: d integer(psb_ipk_), intent(out) :: info end subroutine psb_ls_csr_scals end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_ls_base_maxval interface function psb_ls_csr_maxval(a) result(res) import class(psb_ls_csr_sparse_mat), intent(in) :: a real(psb_spk_) :: res end function psb_ls_csr_maxval end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_ls_base_csnmi interface function psb_ls_csr_csnmi(a) result(res) import class(psb_ls_csr_sparse_mat), intent(in) :: a real(psb_spk_) :: res end function psb_ls_csr_csnmi end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_ls_base_rowsum interface subroutine psb_ls_csr_rowsum(d,a) import class(psb_ls_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) end subroutine psb_ls_csr_rowsum end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_ls_base_arwsum interface subroutine psb_ls_csr_arwsum(d,a) import class(psb_ls_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) end subroutine psb_ls_csr_arwsum end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_ls_base_colsum interface subroutine psb_ls_csr_colsum(d,a) import class(psb_ls_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) end subroutine psb_ls_csr_colsum end interface !> \memberof psb_ls_csr_sparse_mat !! \see psb_s_base_mat_mod::psb_ls_base_aclsum interface subroutine psb_ls_csr_aclsum(d,a) import class(psb_ls_csr_sparse_mat), intent(in) :: a real(psb_spk_), intent(out) :: d(:) end subroutine psb_ls_csr_aclsum end interface contains ! == =================================== ! ! ! ! Getters ! ! ! ! ! ! == =================================== function s_csr_is_by_rows(a) result(res) implicit none class(psb_s_csr_sparse_mat), intent(in) :: a logical :: res res = .true. end function s_csr_is_by_rows function s_csr_sizeof(a) result(res) implicit none class(psb_s_csr_sparse_mat), intent(in) :: a integer(psb_epk_) :: res res = 2 * psb_sizeof_ip res = res + psb_sizeof_sp * psb_size(a%val) res = res + psb_sizeof_ip * psb_size(a%irp) res = res + psb_sizeof_ip * psb_size(a%ja) end function s_csr_sizeof function s_csr_get_fmt() result(res) implicit none character(len=5) :: res res = 'CSR' end function s_csr_get_fmt function s_csr_get_nzeros(a) result(res) implicit none class(psb_s_csr_sparse_mat), intent(in) :: a integer(psb_ipk_) :: res res = a%irp(a%get_nrows()+1)-1 end function s_csr_get_nzeros function s_csr_get_size(a) result(res) implicit none class(psb_s_csr_sparse_mat), intent(in) :: a integer(psb_ipk_) :: res res = -1 if (allocated(a%ja)) then res = size(a%ja) end if if (allocated(a%val)) then if (res >= 0) then res = min(res,size(a%val)) else res = size(a%val) end if end if end function s_csr_get_size function s_csr_get_nz_row(idx,a) result(res) implicit none class(psb_s_csr_sparse_mat), intent(in) :: a integer(psb_ipk_), intent(in) :: idx integer(psb_ipk_) :: res res = 0 if ((1<=idx).and.(idx<=a%get_nrows())) then res = a%irp(idx+1)-a%irp(idx) end if end function s_csr_get_nz_row ! == =================================== ! ! ! ! Data management ! ! ! ! ! ! == =================================== subroutine s_csr_free(a) implicit none class(psb_s_csr_sparse_mat), intent(inout) :: a if (allocated(a%irp)) deallocate(a%irp) if (allocated(a%ja)) deallocate(a%ja) if (allocated(a%val)) deallocate(a%val) call a%set_null() call a%set_nrows(0_psb_ipk_) call a%set_ncols(0_psb_ipk_) return end subroutine s_csr_free ! == =================================== ! ! ! ! Getters ! ! ! ! ! ! == =================================== function ls_csr_is_by_rows(a) result(res) implicit none class(psb_ls_csr_sparse_mat), intent(in) :: a logical :: res res = .true. end function ls_csr_is_by_rows function ls_csr_sizeof(a) result(res) implicit none class(psb_ls_csr_sparse_mat), intent(in) :: a integer(psb_epk_) :: res res = 2 * psb_sizeof_lp res = res + psb_sizeof_sp * psb_size(a%val) res = res + psb_sizeof_lp * psb_size(a%irp) res = res + psb_sizeof_lp * psb_size(a%ja) end function ls_csr_sizeof function ls_csr_get_fmt() result(res) implicit none character(len=5) :: res res = 'CSR' end function ls_csr_get_fmt function ls_csr_get_nzeros(a) result(res) implicit none class(psb_ls_csr_sparse_mat), intent(in) :: a integer(psb_lpk_) :: res res = a%irp(a%get_nrows()+1)-1 end function ls_csr_get_nzeros function ls_csr_get_size(a) result(res) implicit none class(psb_ls_csr_sparse_mat), intent(in) :: a integer(psb_lpk_) :: res res = -1 if (allocated(a%ja)) then res = size(a%ja) end if if (allocated(a%val)) then if (res >= 0) then res = min(res,size(a%val)) else res = size(a%val) end if end if end function ls_csr_get_size function ls_csr_get_nz_row(idx,a) result(res) implicit none class(psb_ls_csr_sparse_mat), intent(in) :: a integer(psb_lpk_), intent(in) :: idx integer(psb_lpk_) :: res res = 0 if ((1<=idx).and.(idx<=a%get_nrows())) then res = a%irp(idx+1)-a%irp(idx) end if end function ls_csr_get_nz_row ! == =================================== ! ! ! ! Data management ! ! ! ! ! ! == =================================== subroutine ls_csr_free(a) implicit none class(psb_ls_csr_sparse_mat), intent(inout) :: a if (allocated(a%irp)) deallocate(a%irp) if (allocated(a%ja)) deallocate(a%ja) if (allocated(a%val)) deallocate(a%val) call a%set_null() call a%set_nrows(0_psb_lpk_) call a%set_ncols(0_psb_lpk_) return end subroutine ls_csr_free end module psb_s_csr_mat_mod
[GOAL] m : Type u_1 n : Type u_2 α : Type u_3 inst✝³ : Fintype n inst✝² : DecidableEq n inst✝¹ : Semiring α A : Matrix n n α B : Matrix n m α inst✝ : Invertible A ⊢ ⅟A * (A * B) = B [PROOFSTEP] rw [← Matrix.mul_assoc, invOf_mul_self, Matrix.one_mul] [GOAL] m : Type u_1 n : Type u_2 α : Type u_3 inst✝³ : Fintype n inst✝² : DecidableEq n inst✝¹ : Semiring α A : Matrix n n α B : Matrix n m α inst✝ : Invertible A ⊢ A * (⅟A * B) = B [PROOFSTEP] rw [← Matrix.mul_assoc, mul_invOf_self, Matrix.one_mul] [GOAL] m : Type u_1 n : Type u_2 α : Type u_3 inst✝³ : Fintype n inst✝² : DecidableEq n inst✝¹ : Semiring α A : Matrix m n α B : Matrix n n α inst✝ : Invertible B ⊢ A * ⅟B * B = A [PROOFSTEP] rw [Matrix.mul_assoc, invOf_mul_self, Matrix.mul_one] [GOAL] m : Type u_1 n : Type u_2 α : Type u_3 inst✝³ : Fintype n inst✝² : DecidableEq n inst✝¹ : Semiring α A : Matrix m n α B : Matrix n n α inst✝ : Invertible B ⊢ A * B * ⅟B = A [PROOFSTEP] rw [Matrix.mul_assoc, mul_invOf_self, Matrix.mul_one]
Module MineSweeper. Require Import Arith Omega. Set Implicit Arguments. Section vector. Variable A: Type. Inductive vector : nat -> Type := | vnil : vector 0 | vcons : forall (a:A) (n:nat), vector n -> vector (S n) . End vector. Implicit Arguments vnil [A]. Delimit Scope vector_scope with vec. Open Scope vector_scope. Infix "::" := vcons (at level 60, right associativity) : vector_scope. Notation "[]" := vnil: vector_scope. Notation "[ x , .. , z ]" := (x :: .. (z :: []) ..) (at level 0) : vector_scope. Section vmap. Variables X Y: Type. Variable f: X -> Y. Fixpoint vmap {n} (v: vector X n): vector Y n := match v with | vnil => vnil | vcons a _ v' => vcons (f a) (vmap v') end. End vmap. Section vzip. Variables X Y Z: Type. Variable f: X -> Y -> Z. Fixpoint vzip {n} (v1: vector X n) (v2: vector Y n): vector Z n. destruct v1. constructor. inversion v2. constructor. apply f. exact a. exact a0. apply vzip. exact v1. exact X0. Defined. End vzip. Definition vi0 {m}: 0 < S m := lt_0_Sn m. Definition viS {n m}: n < m -> S n < S m := lt_n_S n m. Notation "!0" := vi0. Notation "!+ i" := (viS i) (at level 5, right associativity). Section viget. Variable A: Type. Lemma lt_0_False: forall n, n < 0 -> False. intros. omega. Qed. Fixpoint viget {n} (v: vector A n) m (H: m < n): A. destruct v. (* vnil *) apply lt_0_False in H. destruct H. destruct m. (* 0 *) exact a. (* (S _) *) apply viget with (n:=n) (m:=m). exact v. apply lt_S_n. exact H. Defined. End viget. Notation "v '_[' i ]" := (viget v i) (at level 7, left associativity) : vector_scope. Section viset. Variable A: Type. Fixpoint viset {n} (v: vector A n) m (H: m < n) (b:A) {struct v}: vector A n. destruct v as [|a n' v']. (* vnil => False *) apply lt_0_False in H. destruct H. destruct m. (* 0 *) exact (b::v'). (* S _ *) apply (fun v''=> a::v''). apply viset with m; try assumption. apply lt_S_n. assumption. Defined. End viset. Notation "v '_[' i ] / b" := (viset v i b) (at level 7, b at level 50, left associativity) : vector_scope. Delimit Scope matrix_scope with mat. Open Scope matrix_scope. Notation "'mlengths'" := (vector nat) (at level 0) : matrix_scope. Section matrix. Variable A: Type. Inductive matrix: forall n, mlengths n -> Type := | mscalar: A -> matrix [] | mvector: forall n m v, vector (@matrix n v) m -> @matrix (S n) (m::v) . End matrix. Notation "''{}'" := (mvector []%vec): matrix_scope. Notation "'#{' x , .. , z }" := (mvector (x :: .. (z :: []) ..)%vec) (at level 0) : matrix_scope. Notation "''{' x , .. , z }" := (mvector (mscalar x :: .. (mscalar z :: []) ..)%vec) (at level 0) : matrix_scope. Section fillvec. Variable A: Type. Variable a: A. Fixpoint fillvec n: vector A n := match n with | O => vnil | S n' => a :: fillvec n' end. End fillvec. Section fillmat. Variable A: Type. Variable a: A. Fixpoint fillmat n (v: mlengths n): matrix A v. destruct n as [|n']. (* n = O *) dependent inversion v. constructor. assumption. (* n = S n' *) dependent inversion v; subst. constructor. apply fillvec. apply fillmat. Defined. End fillmat. Section mmap. Variables A B: Type. Variable f: A -> B. Fixpoint mmap n (v: mlengths n) (m: matrix A v): matrix B v. destruct n as [|n']. (* n = O *) dependent inversion v; subst. inversion m; subst. apply mscalar. apply f. assumption. (* n = S n' *) inversion m as [|l'' m'' v'']; subst. clear H. constructor. specialize (mmap n' v''). apply (vmap mmap). exact X. Defined. End mmap. Require Import Eqdep_dec. Section mzip. Variables A B C: Type. Variable f: A -> B -> C. Fixpoint mzip n (v: mlengths n) (m1: matrix A v) (m2: matrix B v): matrix C v. destruct n as [|n']. (* n = 0 *) inversion m1. inversion m2. apply mscalar; apply f; assumption. (* n = S n' *) inversion m1 as [|? m1' l1 v1 H1 Heq1]; subst. inversion m2 as [|? m2' l2 v2 H2 Heq2]; subst. apply (inj_pair2_eq_dec _ eq_nat_dec _ _ _) in Heq1. apply (inj_pair2_eq_dec _ eq_nat_dec _ _ _) in Heq2. assert (Heq: m1' :: l1 = m2' :: l2). eapply eq_trans. apply Heq1. symmetry. exact Heq2. clear Heq1. clear Heq2. assert (Heqm: m1' = m2') by (inversion Heq; reflexivity). assert (Heql: l1 = l2). inversion Heq. apply (Eqdep_dec.inj_pair2_eq_dec _ eq_nat_dec _ _ _) in H1. exact H1. clear Heq. rename l2 into l. rename m2' into m'. subst. apply mvector. specialize (mzip n' l). apply (vzip mzip); assumption. Defined. End mzip. Example mzip_ex1: mzip plus '{1,2} '{3,4} = '{4,6}. Proof. simpl. (* 1 subgoal ______________________________________(1/1) eq_rect_r (fun l1 : mlengths 0 => vector (matrix nat l1) 2 -> matrix nat (2 :: l1)) (fun v1 : vector (matrix nat []) 2 => eq_rect_r (fun m1' : nat => vector (matrix nat []) m1' -> matrix nat [m1']) (fun v0 : vector (matrix nat []) 2 => mvector ...... *) Abort.
[STATEMENT] lemma "''et+'' \<in> - (internal_iface_name_to_set ''eth+'')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. ''et+'' \<in> - internal_iface_name_to_set ''eth+'' [PROOF STEP] by(simp)
function [V,F,UV,C,N] = readOFF( filename ) % READOFF reads an OFF file with vertex/face information % % [V,F,UV,C,N] = readOFF( filename ) % % Input: % filename path to .off file % Outputs: % V #V by 3 list of vertices % F #F by 3 list of triangle indices % UV #V by 2 list of texture coordinates % C #V by 3 list of colors % N #V by 3 list of normals % % See also: load_mesh, readOBJfast, readOBJ % (C) 2007 Denis Kovacs, NYU %------------------------------------------------------------------------- V = []; F = []; UV = []; C = []; N = []; fp = fopen( filename, 'r' ); OFFheader = upper(fscanf( fp, '%s\n', 1 )); if OFFheader(end-2:end) ~= 'OFF' warning('no OFF file!') fclose(fp); return; end OFFdim = 3; OFF_N = 0; OFF_C=0; OFF_ST=0; if find(OFFheader=='N') OFFdim = OFFdim+3; OFF_N=1; end if find(OFFheader=='C') OFFdim = OFFdim+3; OFF_C=1; end if find(OFFheader=='S') OFFdim = OFFdim+2; OFF_ST=1; end % eat any comments before line = eat_comments(fp,'#'); d = sscanf( line, '%d', 3); nV = d(1); nF = d(2); nE = d(3); %disp(sprintf(' - Reading %d vertices', nV)); switch OFFdim case 3; OFFV = textscan( fp, '%f %f %f', nV); case 5; OFFV = textscan( fp, '%f %f %f %f %f', nV); case 6; OFFV = textscan( fp, '%f %f %f %f %f %f', nV); case 7; OFFV = textscan( fp, '%f %f %f %f %f %f %f', nV); case 8; OFFV = textscan( fp, '%f %f %f %f %f %f %f %f', nV); case 9; OFFV = textscan( fp, '%f %f %f %f %f %f %f %f %f', nV); case 10; OFFV = textscan( fp, '%f %f %f %f %f %f %f %f %f %f', nV); case 11; OFFV = textscan( fp, '%f %f %f %f %f %f %f %f %f %f %f', nV); otherwise; fclose(fp); error('Unsupported number of vertex entries'); end try OFFV = cell2mat(OFFV); end OFFdim = 1; V = OFFV(:,OFFdim:(OFFdim+2)); OFFdim = OFFdim + 3; if (OFF_N) N = OFFV(:,OFFdim:(OFFdim+2)); OFFdim = OFFdim + 3; end if (OFF_C) C = OFFV(:,OFFdim:(OFFdim+2)); OFFdim = OFFdim + 3; end if (OFF_ST) UV = OFFV(:,OFFdim:(OFFdim+1)); OFFdim = OFFdim + 2; end if (nF ~= 0) %disp(sprintf(' - Reading %d faces', nF)); temp = textscan( fp, '%d %d %d %d %d %d %d %d %d %d %d', nF ); sz = temp{1}(1); if all(sz == cell2mat(temp(1))) F = double (cell2mat( temp(2:sz+1 ))) +1; else warning('Trivially triangulating high degree facets'); F = zeros(sum(temp{1}-2),3); fi = 1; for f = 1:size(temp{1},1) for j = 3:temp{1}(f); F(fi,:) = [temp{2}(f) temp{j}(f) temp{j+1}(f)]+1; fi = fi+1; end end end else F = []; end fclose(fp); %disp(' - done.'); end
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE ScopedTypeVariables #-} module ImageLoader ( loadExamples , loadNonExamples ) where -------------------------------------------------------------------------------- import Control.Exception ( Exception , try ) import Control.Monad ( sequence ) import System.FilePath ( FilePath , (</>) ) import Vision.Image.Type ( manifestVector ) import Vision.Image.RGB.Type ( RGB ) import Vision.Image.Grey.Type ( Grey ) import Vision.Image.Storage.DevIL ( Autodetect (..) , load ) import Paths_img_neural ( getDataFileName ) import qualified Data.Vector.Storable as VS import qualified Numeric.LinearAlgebra.Data as VD -------------------------------------------------------------------------------- type Samples = [(VD.Vector Double, VD.Vector Double)] -- Load the vectors which represent an example of the letter A loadExamples :: Exception e => IO (Either e Samples) loadExamples = try $ do images <- loadImages exampleImageNames return $ map (\x -> (x, output)) images where output = VD.fromList [1 :: Double] -- Load the vectors which do not represent an example of the letter A loadNonExamples :: Exception e => IO (Either e Samples) loadNonExamples = try $ do images <- loadImages nonExampleImageNames return $ map (\x -> (x, output)) images where output = VD.fromList [0 :: Double] -------------------------------------------------------------------------------- -- Lists all images that are examples of the letter A exampleImageNames :: [FilePath] exampleImageNames = map ("A" </>) [ "A1.png" , "A2.png" , "A3.png" , "A4.png" , "A5.png" , "A6.png" ] -- Lists all images that are _not_ examples of the letter A nonExampleImageNames :: [FilePath] nonExampleImageNames = map ("not-A" </>) [ "B1.png" , "B2.png" , "B3.png" , "B4.png" , "B5.png" , "B6.png" , "B7.png" ] -- Loads images from the given list loadImages :: [FilePath] -> IO [VD.Vector Double] loadImages fp = do fnames <- map' getFileName fp vectors <- map' loadFile fnames return $ map convertToLinearVector vectors where map' f xs = sequence $ map f xs getFileName = getDataFileName . ("res" </>) -- Loads the given file to an image, converted to a Vector loadFile :: FilePath -> IO (VS.Vector Double) loadFile f = do dat <- load Autodetect f case dat of Left e -> error $ show e Right (i :: Grey) -> return $ greyManifestToVector i -- Converts a Grey into a Vector Int greyManifestToVector :: Grey -> VS.Vector Double greyManifestToVector m = VS.map (\i -> 1 - (fromIntegral $ round $ (fromIntegral i)/256)) (manifestVector m) -- Converts a Data/Vector to a LinearAlgebra/Vector convertToLinearVector :: VS.Storable a => VS.Vector a -> VD.Vector a convertToLinearVector = VD.fromList . VS.toList
pack.circles <- function(rfix, xfix, size=c(100, 100), max.iter=10, overlap=0 ) { # # Simple circle packing algorithm based on inverse size weighted repulsion # # config - matrix with two cols: radius, N # size - width and height of bounding rectangle # max.iter - maximum number of iterations to try # overlap - allowable overlap expressed as proportion of joint radii # ============================================================================ # Global constants # ============================================================================ # round-off tolerance TOL <- 0.0001 # convert overlap to proportion of radius if (overlap < 0 | overlap >= 1) { stop("overlap should be in the range [0, 1)") } PRADIUS <- 1 - overlap NCIRCLES <- length(rfix) # ============================================================================ # Helper function - Draw a circle # ============================================================================ draw.circle <- function(x, y, r, col) { lines( cos(seq(0, 2*pi, pi/180)) * r + x, sin(seq(0, 2*pi, pi/180)) * r + y , col=col ) } # ============================================================================ # Helper function - Move two circles apart. The proportion of the required # distance moved by each circle is proportional to the size of the other # circle. For example, If a c1 with radius r1 overlaps c2 with radius r2, # and the movement distance required to separate them is ds, then c1 will # move ds * r2 / (r1 + r2) while c2 will move ds * r1 / (r1 + r2). Thus, # when a big circle overlaps a little one, the little one moves a lot while # the big one moves a little. # ============================================================================ repel <- function(xyr, c0, c1) { dx <- xyr[c1, 1] - xyr[c0, 1] dy <- xyr[c1, 2] - xyr[c0, 2] d <- sqrt(dx*dx + dy*dy) r <- xyr[c1, 3] + xyr[c0, 3] w0 <- xyr[c1, 3] / r w1 <- xyr[c0, 3] / r if (d < r - TOL) { p <- (r - d) / d # xyr[c1, 1] <<- toroid(xyr[c1, 1] + p*dx*w1, 1) xyr[c1, 2] <<- toroid(xyr[c1, 2] + p*dy*w1, 2) # xyr[c0, 1] <<- toroid(xyr[c0, 1] - p*dx*w0, 1) xyr[c0, 2] <<- toroid(xyr[c0, 2] - p*dy*w0, 2) return(TRUE) } return(FALSE) } # ============================================================================ # Helper function - Adjust a coordinate such that if it is distance d beyond # an edge (ie. outside the area) it is moved to be distance d inside the # opposite edge. This has the effect of treating the area as a toroid. # ============================================================================ toroid <- function(coord, axis) { tcoord <- coord if (coord < 0) { tcoord <- coord + size[axis] } else if (coord >= size[axis]) { tcoord <- coord - size[axis] } tcoord } # ============================================================================ # Main program # ============================================================================ # ------------------------------------------ # create a random initial layout # ------------------------------------------ xyr <- matrix(0, NCIRCLES, 3) # generate random y axis all_y <- runif(NCIRCLES, size[2] * 0.3, size[2] * 0.7) # arrange y axis so larger dot in the middle generated.rank <- order(abs(all_y - size[2] / 2), decreasing = TRUE) data.rank <- order(rfix) for (i in 1:length(rfix)) { # rearranging x axis to new size xyr[i, 1] <- (xfix[i] - min(xfix))/(max(xfix) - min(xfix)) * size[1] xyr[data.rank[i], 2] <- all_y[generated.rank[i]] xyr[i, 3] <- rfix[i] * PRADIUS } # ------------------------------------------ # iteratively adjust the layout # ------------------------------------------ for (iter in 1:max.iter) { moved <- FALSE for (i in 1:(NCIRCLES-1)) { for (j in (i+1):NCIRCLES) { if (repel(xyr, i, j)) { moved <- TRUE } } } cat(".") if (!moved) break } cat(paste(iter, "iterations\n")); # ------------------------------------------ # draw the layout # ------------------------------------------ plot(0, type="n", xlab="x", xlim=c(0,size[1]), ylab="y", ylim=c(0, size[2])) xyr[, 3] <- xyr[, 3] / PRADIUS for (i in 1:nrow(xyr)) { draw.circle(xyr[i, 1], xyr[i, 2], xyr[i, 3], "gray") } # ------------------------------------------ # return the layout # ------------------------------------------ colnames(xyr) <- c("x", "y", "radius") invisible(xyr) }
\chapter*{Abstract} foo bar \chapter*{Zusammenfassung} German version is only needed for an undergraduate thesis.
import numpy as np class ReverseScalar(): def __init__(self, val: float): self._val = val self._gradient = 1 self._children = {} def get(self): return self._val, self.compute_gradient() def compute_gradient(self): if len(self._children.keys()) > 0: gradient = 0 for node, val in self._children.items(): gradient += val*node.compute_gradient() return gradient #return sum([val * node.compute_gradient() for node, val in self._children.items()]) #except TypeError: # return self._gradient else: return 1 def __add__(self, other): try: # If scalar child = ReverseScalar(self._val+other._val) child._children[self] = 1 child._children[other] = 1 return child except AttributeError: # If constant child = ReverseScalar(self._val+other) child._children[self] = 1 return child def __radd__(self, other): return self.__add__(other) def __sub__(self, other): try: # If scalar child = ReverseScalar(self._val-other._val) child._children[self] = 1 child._children[other] = -1 return child except AttributeError: # If constant child = ReverseScalar(self._val-other) child._children[self] = 1 return child def __rsub__(self, other): try: # If scalar child = ReverseScalar(other._val- self._val) child._children[self] = -1 child._children[other] = 1 return child except AttributeError: # If constant child = ReverseScalar(other-self._val) child._children[self] = -1 return child def __mul__(self, other): try: # If scalar child = ReverseScalar(self._val*other._val) child._children[self] = other._val child._children[other] = self._val return child except AttributeError: # If constant child = ReverseScalar(self._val*other) child._children[self] = other return child def __rmul__(self, other): return self.__mul__(other) def __truediv__(self, other): try: # If scalar child = ReverseScalar(self._val/other._val) child._children[self] = 1/other._val child._children[other] = -self._val/other._val**2 return child except AttributeError: # If constant child = ReverseScalar(self._val/other) child._children[self] = 1/other return child def __rtruediv__(self, other): # Might be wrong try: # If scalar child = ReverseScalar(other._val/self._val) child._children[self] = -other._val/self._val**2 child._children[other] = 1/self._val return child except AttributeError: # If constant child = ReverseScalar(other/self._val) child._children[self] = -other/self._val**2 return child def __pow__(self, other): try: # If scalar child = ReverseScalar(self._val**other._val) child._children[self] = other._val*self._val**(other._val-1) child._children[other] = np.log(self._val)*self._val**other._val return child except AttributeError: # If constant child = ReverseScalar(self._val**other) child._children[self] = other*self._val**(other-1) return child def __rpow__(self, other): child = ReverseScalar(other**self._val) child._children[self] = np.log(other)*other**self._val return child def __neg__(self): child = ReverseScalar(-self._val) child._children[self] = -1 return child
-- Non-index (plain) monads in form of Kleisli triple. module Control.Monad where open import Function using () renaming (_∘′_ to _∘_) open import Relation.Binary.PropositionalEquality open ≡-Reasoning open import Axiom.FunctionExtensionality open import Control.Functor -- The operations of a monad. module T-MonadOps (M : Set → Set) where T-return = ∀ {A} (a : A) → M A T-bind = ∀ {A B} (m : M A) (k : A → M B) → M B record MonadOps (M : Set → Set) : Set₁ where open T-MonadOps M infixr 6 _>>=_ field return : T-return _>>=_ : T-bind bind = _>>=_ functorOps : FunctorOps M functorOps = record { map = λ f m → m >>= λ a → return (f a) } open FunctorOps functorOps public -- The laws of a monad (Kleisli triple variant). module T-MonadLaws {M : Set → Set} (ops : MonadOps M) where open MonadOps ops public T-bind-β = ∀ {A B} (k : A → M B) (a : A) → return a >>= k ≡ k a T-bind-η = ∀ {A} (m : M A) → m >>= return ≡ m T-bind-assoc = ∀ {A B C} (m : M A) {k : A → M B} {l : B → M C} → (m >>= k) >>= l ≡ m >>= λ a → (k a >>= l) -- Provable laws. -- A variant of bind-β using function extensionality. T-bind-β-ext = ∀ {A B C : Set} (f : A → B) (k : B → M C) → (λ a → return (f a) >>= k) ≡ k ∘ f T-map-after-bind = ∀ {A B C} (m : M A) {k : A → M B} {f : B → C} → f <$> (m >>= k) ≡ m >>= λ a → f <$> k a T-bind-after-map = ∀ {A B C} (m : M A) {k : B → M C} {f : A → B} → (f <$> m) >>= k ≡ m >>= λ a → k (f a) record MonadLaws {M : Set → Set} (ops : MonadOps M) : Set₁ where open T-MonadLaws ops -- Axioms. field bind-β : T-bind-β bind-η : T-bind-η bind-assoc : T-bind-assoc -- Derived laws. bind-β-ext : T-bind-β-ext bind-β-ext f k = fun-ext (λ a → bind-β k (f a)) map-after-bind : T-map-after-bind map-after-bind m = bind-assoc m -- A more detailed proof. (NF: trans (bind-assoc m) refl) private map-after-bind′ : T-map-after-bind map-after-bind′ m {k = k} {f = f} = begin f <$> (m >>= k) ≡⟨⟩ -- definition of map ((m >>= k) >>= λ b → return (f b)) ≡⟨ bind-assoc m ⟩ -- associativity of bind m >>= (λ a → k a >>= λ b → return (f b)) ≡⟨⟩ -- definition of map m >>= (λ a → f <$> k a) ∎ bind-after-map : T-bind-after-map bind-after-map m {k = k} {f = f} = begin (f <$> m) >>= k ≡⟨⟩ -- definition of map (m >>= λ a → return (f a)) >>= k ≡⟨ bind-assoc m ⟩ -- associativity of bind m >>= (λ a → return (f a) >>= k) ≡⟨ cong (_>>=_ m) (bind-β-ext _ _) ⟩ -- beta for bind m >>= (λ a → k (f a)) ∎ -- Functor laws. open T-FunctorLaws functorOps using (T-map-∘) private abstract map-comp : T-map-∘ map-comp {f = f} {g = g} = fun-ext λ m → begin g ∘ f <$> m ≡⟨⟩ (m >>= λ a → return (g (f a))) ≡⟨ cong (_>>=_ m) (sym (bind-β-ext _ _)) ⟩ (m >>= λ a → return (f a) >>= λ b → return (g b)) ≡⟨ sym (bind-assoc m) ⟩ (m >>= λ a → return (f a)) >>= (λ b → return (g b)) ≡⟨⟩ g <$> f <$> m ∎ functorLaws : FunctorLaws functorOps functorLaws = record { map-id = fun-ext bind-η ; map-∘ = map-comp } open FunctorLaws functorLaws public record IsMonad (M : Set → Set) : Set₁ where field ops : MonadOps M laws : MonadLaws ops open MonadOps ops public open MonadLaws laws public {- -- The operations of a monad. record MonadOps (M : Set → Set) : Set₁ where infixr 6 _>>=_ T-return = ∀ {A} (a : A) → M A T-bind = ∀ {A B} (m : M A) (k : A → M B) → M B field return : T-return _>>=_ : T-bind bind = _>>=_ functorOps : FunctorOps M functorOps = record { _<$>_ = λ f m → m >>= λ a → return (f a) } open FunctorOps functorOps public -- The laws of a monad (Kleisli triple variant). record MonadLaws {M : Set → Set} (ops : MonadOps M) : Set₁ where open MonadOps ops T-bind-β = ∀ {A B} (a : A) (k : A → M B) → return a >>= k ≡ k a T-bind-η = ∀ {A} (m : M A) → m >>= return ≡ m T-bind-assoc = ∀ {A B C} (m : M A) {k : A → M B} {l : B → M C} → (m >>= k) >>= l ≡ m >>= λ a → (k a >>= l) field bind-β : T-bind-β bind-η : T-bind-η bind-assoc : T-bind-assoc private abstract map-comp : FunctorLaws.T-map-∘ {!!} map-comp = {!!} functorLaws : FunctorLaws functorOps functorLaws = record { map-id = bind-η ; map-∘ = {!!} } record IsMonad (M : Set → Set) : Set₁ where record IsMonad (M : Set → Set) : Set₁ where infixr 6 _>>=_ field return : ∀ {A} (a : A) → M A _>>=_ : ∀ {A B} (m : M A) (k : A → M B) → M B -- Laws bind-β : ∀ {A B} (a : A) (k : A → M B) → return a >>= k ≡ k a bind-η : ∀ {A} (m : M A) → m >>= return ≡ m bind-assoc : ∀ {A B C} (m : M A) {k : A → M B} {l : B → M C} → (m >>= k) >>= l ≡ m >>= λ a → (k a >>= l) bind = _>>=_ private map : Map-T F map = λ f m → m >>= λ a → return (f a) abstract map-comp : Map-Comp-T map functor : IsFunctor M functor = record { _<$>_ = λ f m → m >>= λ a → return (f a) ; map-id = bind-η ; map-∘ = map-comp where x = {!bind-assoc!} } -}
#include <stdio.h> #include <gsl/gsl_math.h> #include <gsl/gsl_eigen.h> int main (void) { double data[] = { 1.0 , 1/2.0, 1/3.0, 1/4.0, 1/2.0, 1/3.0, 1/4.0, 1/5.0, 1/3.0, 1/4.0, 1/5.0, 1/6.0, 1/4.0, 1/5.0, 1/6.0, 1/7.0 }; gsl_matrix_view m = gsl_matrix_view_array (data, 4, 4); gsl_vector *eval = gsl_vector_alloc (4); gsl_matrix *evec = gsl_matrix_alloc (4, 4); gsl_eigen_symmv_workspace * w = gsl_eigen_symmv_alloc (4); gsl_eigen_symmv (&m.matrix, eval, evec, w); gsl_eigen_symmv_free (w); gsl_eigen_symmv_sort (eval, evec, GSL_EIGEN_SORT_ABS_ASC); { int i; for (i = 0; i < 4; i++) { double eval_i = gsl_vector_get (eval, i); gsl_vector_view evec_i = gsl_matrix_column (evec, i); printf ("eigenvalue = %g\n", eval_i); printf ("eigenvector = \n"); gsl_vector_fprintf (stdout, &evec_i.vector, "%g"); } } gsl_vector_free (eval); gsl_matrix_free (evec); return 0; }
```python # Aquí van las librerías y funciones que va a usar %matplotlib inline import matplotlib.pyplot as plt import sympy as sym from sympy import oo sym.init_printing() ## Puede que requiera incorporar más librerías o definir nuevas funciones. Hágalo a continuación ``` ## Tarea Nombres: **Ponga aquí sus nombres completos separados por coma** Suponga que tiene un sistema de tiempo continuo que se excita con una entrada $x(t)$ y responde con una señal $y(t)$, como lo muestra la figura: Analice el modelo del sistema para los modelos en cada uno de los casos siguientes: |Caso | Ecuación | |------|----------------------------------------------------------------------------------------| | A | \begin{equation} \frac{dy}{dt} + 5y(t) = 5x(t) \end{equation} | | B | \begin{equation} \frac{dy}{dt} - 5y(t) = 5x(t) \end{equation} | | C | \begin{equation} \frac{d^{2}y}{dt^{2}} + 5\frac{dy}{dt} + y(t) = x(t) \end{equation} | | D | \begin{equation} \frac{d^{2}y}{dt^{2}} + y(t) = x(t) \end{equation} | ### Análisis - Lleve la ecuación diferencial al dominio de las frecuencias usando la transformada de Laplace. \begin{equation} EscribaAquíLaEcuaciónTransformada \end{equation} - Encuentre la función de transferencia del sistema. \begin{equation} F_A(s) = EscribaAquíLaFunciónDeTransferencia \end{equation} - Grafique el mapa de polos y ceros - Grafique la respuesta al escalón ```python ## Aquí va el código para generar la gráfica pedida. Ejecute el código para generar la gráfica. ``` - Analice las gráfica obtenidas, escriba su análisis y determine la estabilidad del sistema y el tipo de amortiguamiento. - Escriba aquí su discusión. - Puede usar viñetas o párrafos. - Conserve las sangrías para facilitar la lectura. ```python ## Aquí va el código extra que puede requerir para responder a las preguntas. ``` Suponga que los sistemas $B$ y $C$ interactúan de manera que la salida de $B$ es la entrada de $C$. - ¿Cuál es la función de transferencia equivalente para estos sistemas conectados? - Grafique el mapa de polos y ceros - Grafique la respuesta al escalón ```python ## Aquí va el código para generar la gráfica pedida. Ejecute el código para generar la gráfica. ``` - Analice la gráfica obtenida, escriba su análisis y determine la estabilidad del sistema y el tipo de amortiguamiento. - Escriba aquí su discusión. - Puede usar viñetas o párrafos. - Conserve las sangrías para facilitar la lectura. ## Análisis comparativo Con base en los resultados anteriores, realice un análisis comparativo y escriba sus observaciones - Escriba aquí sus respuestas - Puede usar viñetas ## Conclusiones Escriba sus conclusiones - Use viñetas
she's too pretty for words! ^ I know! I am so jealous of her, shes so beautiful! I like that she's got a solid head on her shoulders and she isn't arrogant or showy. Loved her in Star Wars. I am a huge Indiana Jones fan, I have been waiting for this new movie for what feels like 5 years already. it has been in talk FOREVER, any new news is good news!!! she's beautiful and intelligent, what a combination. I love her at the end of the movie "Closer"...she must be way more stunning IRL , the guys were giving her second,third look. It was shot in the crowded street. She can look pretty when bald. I don't think I can! she looks really gorgeous here. can't wait for my issue to arrive! i'm def picking that up when it hits the stands.
[STATEMENT] lemma fresh_vquot_dbtm [simp]: "i \<sharp> vquot_dbtm V tm \<longleftrightarrow> i \<sharp> tm \<or> i \<notin> atom ` V" [PROOF STATE] proof (prove) goal (1 subgoal): 1. i \<sharp> vquot_dbtm V tm = (i \<sharp> tm \<or> i \<notin> atom ` V) [PROOF STEP] by (induct tm rule: dbtm.induct) (auto simp: fresh_at_base pure_fresh)
export Dirichlet, Neumann, GeneralBoundaryConditions, SurfaceDrivenWaterBoundaryConditions abstract type AbstractBoundaryFunctions end """ struct Dirichlet{Fs, Fb} <: AbstractBoundaryFunctions A concrete type to hold the surface state and bottom state variable values/functions, if Dirichlet boundary conditions are desired. # Fields $(DocStringExtensions.FIELDS) """ Base.@kwdef struct Dirichlet{Fs, Fb} <: AbstractBoundaryFunctions "Surface state boundary condition" surface_state::Fs = nothing "Bottom state boundary condition" bottom_state::Fb = nothing end """ struct Neumann{Fs, Fb} <: AbstractBoundaryFunctions A concrete type to hold the surface and/or bottom diffusive flux values/functions, if Neumann boundary conditions are desired. Note that these are intended to be scalar values. In the boundary_state! functions, they are multiplied by the `ẑ` vector (i.e. the normal vector `n̂` to the domain at the upper boundary, and -`n̂` at the lower boundary. These normal vectors point out of the domain.) # Fields $(DocStringExtensions.FIELDS) """ Base.@kwdef struct Neumann{Fs, Fb} <: AbstractBoundaryFunctions "Surface flux boundary condition" surface_flux::Fs = nothing "Bottom flux boundary condition" bottom_flux::Fb = nothing end """ AbstractBoundaryConditions """ abstract type AbstractBoundaryConditions end """ GeneralBoundaryConditions{D, N} <: AbstractBoundaryConditions A concrete example of the abstract type `AbstractBoundaryConditions`; to be used when the user wishes to supply specific functions of space and time for boundary conditions, at either the top or bottom of the domain, and either of type Neumann or Dirichlet. # Fields $(DocStringExtensions.FIELDS) """ struct GeneralBoundaryConditions{D, N} <: AbstractBoundaryConditions "Place to store Dirichlet Boundary conditions" dirichlet_bc::D "Place to store Neumann Boundary conditions" neumann_bc::N end """ GeneralBoundaryConditions( dirichlet_bc::AbstractBoundaryFunctions = Dirichlet(), neumann_bc::AbstractBoundaryFunctions = Neumann(), ) Constructor for the GeneralBoundaryConditions object. The default is `nothing` boundary functions for the top and bottom of the domain, for both Dirichlet and Neumann types. The user must change these in order to apply boundary conditions. """ function GeneralBoundaryConditions( dirichlet_bc::AbstractBoundaryFunctions = Dirichlet(), neumann_bc::AbstractBoundaryFunctions = Neumann(), ) args = (dirichlet_bc, neumann_bc) return GeneralBoundaryConditions{typeof.(args)...}(args...) end """ SurfaceDrivenWaterBoundaryConditions{FT, PD, RD} <: AbstractBoundaryConditions A concrete example of AbstractBoundaryConditions; this is to be used when the user wishes to apply physical fluxes of water at the top of the domain (according to precipitation, runoff, and evaporation rates) and zero flux at the bottom of the domain. # Fields $(DocStringExtensions.FIELDS) """ struct SurfaceDrivenWaterBoundaryConditions{FT, PD, RD} <: AbstractBoundaryConditions where {FT, PD, RD} "Precipitation model" precip_model::PD "Runoff model" runoff_model::RD end """ SurfaceDrivenWaterBoundaryConditions( ::Type{FT}; precip_model::AbstractPrecipModel{FT} = DrivenConstantPrecip{FT}(), runoff_model::AbstractSurfaceRunoffModel{FT} = NoRunoff(), ) where {FT} Constructor for the SurfaceDrivenWaterBoundaryConditions object. The default is a constant precipitation rate on the subgrid scale, and no runoff. """ function SurfaceDrivenWaterBoundaryConditions( ::Type{FT}; precip_model::AbstractPrecipModel{FT} = DrivenConstantPrecip{FT}( (t) -> (0.0), ), runoff_model::AbstractSurfaceRunoffModel = NoRunoff(), ) where {FT} args = (precip_model, runoff_model) return SurfaceDrivenWaterBoundaryConditions{FT, typeof.(args)...}(args...) end
% Options for packages loaded elsewhere \PassOptionsToPackage{unicode}{hyperref} \PassOptionsToPackage{hyphens}{url} % \documentclass[ ]{book} \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{ pdftitle={Statistics for Behavioral Sciences}, hidelinks, pdfcreator={LaTeX via pandoc}} \urlstyle{same} % disable monospaced font for URLs \usepackage{longtable,booktabs} % Correct order of tables after \paragraph or \subparagraph \usepackage{etoolbox} \makeatletter \patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{} \makeatother % Allow footnotes in longtable head/foot \IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} \makesavenoteenv{longtable} \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 \setlength{\emergencystretch}{3em} % prevent overfull lines \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} \setcounter{secnumdepth}{5} \usepackage{booktabs} \usepackage{amsthm} \makeatletter \def\thm@space@setup{% \thm@preskip=8pt plus 2pt minus 4pt \thm@postskip=\thm@preskip } \makeatother \usepackage[]{natbib} \bibliographystyle{apalike} \title{Statistics for Behavioral Sciences} \author{} \date{\vspace{-2.5em}Summer 2021} \begin{document} \maketitle { \setcounter{tocdepth}{1} \tableofcontents } \hypertarget{syllabus}{% \chapter{Syllabus}\label{syllabus}} \hypertarget{instructors}{% \section{Instructors}\label{instructors}} \textbf{Professor}: Kelsey Moty\\ \textbf{Email}: moty at nyu dot edu\\ \textbf{Office Hours}: By appointment (schedule via \href{https://calendly.com/kelseymoty/stats-office-hours}{Calendly} or by email, if none of the available slots work for you)\\ \textbf{Office}: The zoom world \textbf{Teaching Assistant}: Ben Stillerman\\ \textbf{Email}: ben.stillerman at nyu dot edu\\ \textbf{Office Hours}: By appointment (schedule via email) \hypertarget{place-and-time}{% \section{Place and Time}\label{place-and-time}} Zoom (see zoom link in Brightspace)\\ M/T/W 9:00 - 11:45 am (generally with an intermission halfway through) \hypertarget{course-overview}{% \section{Course Overview}\label{course-overview}} The goal of this class is for you to become statistically literate. I think of this as driver's ed for statistics. Most of you won't end up being researchers or statisticians in the same way that most of you won't end up being auto mechanics or engineers for GM. You still benefit from knowing what a car is and how to operate it. Similarly, you will benefit from knowing what statistics is and a little bit about how to use it. For those of you who do want to go on to use statistics professionally, this will give you a strong foundation. By the end of the class, you will be able to: \begin{enumerate} \def\labelenumi{\arabic{enumi}.} \tightlist \item Recognize different kinds of variables and data. \item Understand most standard charts and graphs. \item Read and understand statistical reports. \item Conduct basic analyses of your own using statistical software. \end{enumerate} \hypertarget{textbooks}{% \section{Textbooks}\label{textbooks}} We're going to use a couple of different textbooks. All are optional but also free and useful, so I gotta suggest, take a look. Cohen, B.H. (2013). Explaining Psychological Statistics (4th Ed). Wiley. --- This textbook is freely available through NYU. \href{https://ebookcentral.proquest.com/lib/nyulibrary-ebooks/detail.action?docID=1563061}{Click this link} \textgreater{} then click ``Download Book''. You'll need to create a quick ProQuest account (name/email/pw) and download Adobe Digital Editions, which are both free. \href{https://r4ds.had.co.nz/}{R for Data Science} --- It's free! It's online! It will teach you R! Good if you want to learn how to code or are interested in data science. \href{https://learningstatisticswithr.com/}{Learning Statistics with R} and \href{https://learnstatswithjasp.com/}{Learning Statistics with JASP} -- Also free and online! They will teach you R and JASP! Extra points for the engaging way in which Danielle Navarro writes. \hypertarget{statistical-software}{% \subsection{Statistical Software}\label{statistical-software}} Note that part of the class will be learning to use statistical software for data analysis. Specifically, R and JASP. JASP is available for \href{https://jasp-stats.org/download/}{free download here}. If you plan to use R, you will want to \href{https://cran.r-project.org/}{download R} as well as \href{https://www.rstudio.com/products/rstudio/download/}{RStudio}; both are free. Alternatively, you can make a \href{https://www.rstudio.com/products/cloud/}{free RStudio Cloud account} to get started with R. Using the cloud version ensures that everything has been properly installed and you'll have no issues when trying to load packages. We will be teaching these skills (using R and JASP) in the class. However, if you find that you need extra assistance (particularly in learning R / they don't appear to have support for JASP), Bobst library provides software-specific tutorials as well as statistical consultants who are familiar with R. For more details, see \href{https://guides.nyu.edu/c.php?g=277138\&p=1847146}{their website}. \hypertarget{assignments}{% \section{Assignments}\label{assignments}} \hypertarget{exams-50-using-only-your-highest-exam-grade}{% \subsection{Exams (50\%, using only your highest exam grade)}\label{exams-50-using-only-your-highest-exam-grade}} Rather than multiple exams that cover different portions of the material, you will take a final exam at the end of every week. The exams will have \textbf{nearly identical formats}, differing only in the particulars. \textbf{All exams are final exams}, meaning they cover \textbf{all of the material covered in the whole course}. This means you will have a final exam at the end of Week 1, at the end of Week 2, at the end of Week 3, and so on\ldots{} Since these are all final exams, most of you probably won't do very well on the first exam. But that's ok, because: Your exam grade will be \textbf{entirely} based on your \textbf{best exam}. Other exam grades will \textbf{not contribute at all}. If you get a 90\% on the third final, it doesn't matter how you did on the first two. This format has some very specific benefits: \begin{itemize} \tightlist \item \textbf{Low Anxiety:} Students who are able to get a good grade on one of the early tests will be able to worry about things other than cramming for the next test. \item \textbf{Safety Net}: Each exam offers a new chance to set a minimum threshold for your grade. Once you get a 85 on one exam, you can rest easy that your grade won't go any lower. \item \textbf{Transparency}: No more need for, ``what will be on the test?'' Once you have taken the first final, you will know (approximately) the format of all the other finals. \item \textbf{Context}: Seeing all the material at once will allow you to begin building a tapestry of ideas in your head. You will never be blindsided by new material you are expected to know. Once you've seen one final exam you will have a good sense of all of them. Being exposed to all the material early on will help you learn it later. \item \textbf{Good Incentives}: I want to reward you if you fully understand the material quickly. Students who succeed will be rewarded with more freedom. No one who has mastered the material should be forced to go through the motions. If you get a grade you're happy with, you can choose to skip the rest of the exams with no downside. \item \textbf{Feedback}: You will be able to tell what skills you have mastered and which you need to work on. This will allow you to spend your study time wisely. \end{itemize} Exams will be run through the survey software Qualtrics. You will have \textbf{45 minutes to complete the exam} after the survey has been opened, so please be sure to not start the exam until you are able to complete the whole exam. These exams are open note, but must be completed by yourself (no working on exams with other people!). \hypertarget{data-exploration-30-15-per-research-report}{% \subsection{Data Exploration (30\%, 15\% per research report)}\label{data-exploration-30-15-per-research-report}} This is an opportunity for you to gain some experience conducting analyses on your own. In a folder on the Classes website there are a number of text files and matching csv files (a spreadsheet filetype). Each text file describes a (hypothetical) scenario, and the matching .csv includes the related data. For a research report, you pick a dataset and conduct the appropriate analyses on it with the statistical software of your choice (or by hand if you really want to, I guess). In this class, we will be covering how to use R and JASP, but you are free to use other software if you wish. You will not be told exactly which test(s) to run. Instead, you will determine this for yourself based on the scenario in the text file. The end product should be a document in which you describe the analyses you conducted, report the test results, and draw reasonable conclusions. The report has the following requirements: \begin{itemize} \tightlist \item One page long. Longer submissions won't be accepted. I want you to learn to be concise! \item Twelve point font, 1.5-line spacing. \item Report your statistical analyses in (approximately) APA format. We need to be able to understand it, but formatting isn't the point of the assignment. \item Some sort of graph or plot \item Discuss, at least briefly, your conclusions: say what the test results mean for the (hypothetical) study. Also mention if you notice anything strange or have any concerns about the results. \end{itemize} When you are done with a report, submit as a PDF on Brightspace to receive a grade. You are required to do two of these research reports at some point during the class. You can do these two reports at any point during the class, but since you won't be taught how to do most analyses until about halfway through, most of you will probably want to do these assignments during the second half of the course. If you are not satisfied with your grade on one or both of your research reports, you may do a replacement research report on a new dataset. You can only do a replacement report once for each research report. We want you to be able to learn from your mistakes but also I don't want you each doing 10 of these. Essentially this means you can do up to four of these and your grade will be based on your best two. Obviously if you're happy with your first two, you don't need to do four. Please don't complete more than 4, the extras won't be graded. \hypertarget{participation-20}{% \subsection{Participation (20\%)}\label{participation-20}} Measuring participation in an online class that doesn't require attendance is a bit tricky, but I also hope that you will also be actively engaging with the material as it is presented. The best way I can measure participation (at least in my opinion) given these constraints is having you submit a short reflection of what was discussed in lecture that day. \textbf{What should these reflections be about?} Really anything. Maybe there's a topic that wasn't clear to you and would like some clarification on it. Maybe you found a connection between something we discussed today and something we addressed in a previous lecture. Maybe you found something interesting and want more details about it. Or maybe you want to provide some constructive feedback in how I presented something. I'll also ask a number of questions during lecture to encourage participation (and may provide some questions as prompts in the reflection submission box). You can write a response to one of these questions in your reflection if you can't think of anything else. \textbf{What should these reflections look like?} Nothing too formal and nothing particularly long. I don't want to put a specific minimum or maximum length because in the end, I see these reflections as an opportunity for myself to gauge where everyone is with the material (am I going too fast or too slow, etc.). A 2- to 4-sentence paragraph is generally an appropriate length. You won't be graded on grammar (incomplete sentences are ok); as long as a I can easily figure out what you are talking about, you're good. \textbf{When are these due?} Within 36 hours after the lecture ends, but I'd recommend submitting these immediately after you watched/attended lecture. I'm giving a little extra time for you to complete these for a couple of reasons: \begin{itemize} \tightlist \item Some of you are watching these lectures after the fact, so I want there to be enough time for the lecture to load to Brightspace (Zoom can take a couple plus hours for this happen) and for you to watch the lecture \item But also for those attending live, some students may need some time for lectures to consolidate in their minds before they're able to reflect on what they learned. Hopefully this extra time gives students the time they need \end{itemize} \textbf{How many of these do I have to do?} One per lecture, but you can miss up to 2 and still get full credit. So you need to do 15 reflections for the 17 lectures. \hypertarget{extra-credit-research-participation-up-to-2}{% \subsection{Extra Credit: Research Participation (up to 2\%)}\label{extra-credit-research-participation-up-to-2}} Many psychology studies are run at research universities and recruit undergraduates as participants. If you would like, you may participate in a research study for up to 2\% extra credit on your final grade. You will earn 0.5\% extra credit per half hour of research participation (i.e., 2 hours of participation for the full 2\% extra credit). You can sign up for research experiments on Sona (\url{http://nyu-psych.sonasystems.com}), the psychology department's online experiment management system. To start signing up for studies, first request a Sona account at \url{http://nyu-psych.sonasystems.com}. Your login information will be sent to your NYU e-mail address within 24 hours. If you are under 18 years of age, please note that you will need a parent or guardian to sign a Parental Consent form prior to each study you complete. Please read the \href{https://as.nyu.edu/content/dam/nyu-as/psychology/documents/research/research-requirements/AdvancedStudentGuide_Rev2017.pdf}{Advanced Psychology Student Guide} for more details and step-by-step instructions for creating a Sona account and signing up for research studies. If you are under 18 years of age, please note that you will need a parent or guardian to sign a Parental Consent form prior to each study you complete. Any questions/concerns about the research requirement or Sona should be directed to the Subject Pool Administrator, Brenda Woodford-Febres (\href{mailto:[email protected]}{\nolinkurl{[email protected]}}). The deadline for research participation is August 13th. If you are unable to participate in research participation and want another opportunity to earn this extra credit, please reach out by Monday, July 26th to coordinate an alternate assignment. \hypertarget{grading}{% \subsection{Grading}\label{grading}} It is each student's responsibility to monitor their grades online and report any discrepancies to the grader within one week of the contested assignment. DO NOT wait until the end of the term to check your grade. The grading scale is as follows: \begin{longtable}[]{@{}llll@{}} \toprule \endhead A = 93 - 100 & B = 83 - 86 & C = 73 - 76 & D = 63 - 66\tabularnewline A- = 90 - 92 & B- = 80 - 82 & C- = 70 - 72 & D- = 60 - 62\tabularnewline B+ = 87 - 89 & C+ = 77 - 79 & D+ = 67 - 69 & F \textless{} 60\tabularnewline \bottomrule \end{longtable} For questions about Exam or Participation grades, contact Kelsey. For questions about Research Report grades, contact Ben. \hypertarget{schedule}{% \section{Schedule}\label{schedule}} This is the schedule for the semester. This page will be frequently updated based on how we progress (plus I'll add links to extra readings and resources), and everything is subject to change. But this should give you a gist of the general topics that will be covered in this class. If there is something in particular you would like covered in this class (that falls within the purview of an intro stats course) and you do not see it on the syllabus, please reach out to me. \begin{longtable}[]{@{}llll@{}} \toprule \begin{minipage}[b]{0.09\columnwidth}\raggedright \textbf{Week 1}\strut \end{minipage} & \begin{minipage}[b]{0.32\columnwidth}\raggedright \textbf{Part I}\strut \end{minipage} & \begin{minipage}[b]{0.29\columnwidth}\raggedright \textbf{Part II}\strut \end{minipage} & \begin{minipage}[b]{0.18\columnwidth}\raggedright \textbf{Readings (Optional)}\strut \end{minipage}\tabularnewline \midrule \endhead \begin{minipage}[t]{0.09\columnwidth}\raggedright July 6\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Welcome\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright What is statistics?\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/why-do-we-learn-statistics.html}{Why do we learn stats?}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 7\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Intro to Data/Descriptive Stats\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Intro to Inferential Stats\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright \textbf{Week 2}\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 12\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Finishing up intro to Inferential Stats\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Data: Items \& Variables\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://en.wikipedia.org/wiki/Wide_and_narrow_data}{Long vs wide data}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 13\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Data: Data Types\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Intro to JASP\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/studydesign.html\#scales}{Scales of measurement} / \href{https://tomfaulkenberry.github.io/JASPbook/chapters/chapter3.pdf}{Intro to JASP}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 14\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Data: Outliers\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Intro to R\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://scholarworks.umass.edu/cgi/viewcontent.cgi?article=1139\&context=pare}{Outliers} / \href{https://learningstatisticswithr.com/book/introR.html}{Intro to R}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright \textbf{Week 3}\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 19\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Descriptives: Central Tendency \& Dispersion\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Descriptives: Plots 1\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/descriptives.html}{Descriptive Statistics} / \href{https://socvis.co/lookatdata.html\#lookatdata}{Why look at data?}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 20\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Descriptives: Relation\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Descriptives: Plots 2\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/descriptives.html}{Descriptives} / \href{https://learningstatisticswithr.com/book/graphics.html}{Plots}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 22\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: Samples \& Populations\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Inferential: Tests Review\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/lsr-0.6.pdf}{Samples and populations: See Chap 10} / \href{http://tidylsr.djnavarro.net/datavis.html}{Plots}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright \textbf{Week 4}\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 26\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: \emph{p}-values and NHST\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Inferential: Power\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/hypothesistesting.html}{Hypothesis Testing} (You can ignore section 11.9) \href{https://learningstatisticswithr.com/book/estimation.html\#ci}{Confidence Intervals} / \href{https://www.crumplab.com/statistics/thinking-about-answering-questions-with-data.html}{Power and Effect Size}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 27\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: One Sample \emph{t}-test\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Inferential: One-way \(\chi^2\)\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/ttest.html}{\(t\)-test} / \href{https://learningstatisticswithr.com/book/chisquare.html}{\(\chi^2\) test}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright July 28\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: Two Sample \emph{t}-test\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Open Science\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/ttest.html}{\(t\)-test} / See slides for more readings on Open Science\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright \textbf{Week 5}\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright August 2\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: Correlation\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Inferential: Two-way \(\chi^2\)\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/regression.html\#corrhyp}{Correlation} / \href{https://learningstatisticswithr.com/book/chisquare.html}{\(\chi^2\) test}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright August 3\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: Simple Regression\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Inferential: One-way ANOVA\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/regression.html}{Regression} / \href{https://learningstatisticswithr.com/book/anova.html}{One-way ANOVA}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright August 4\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: Multiple Regression\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Inferential: Two-way ANOVA\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \href{https://learningstatisticswithr.com/book/regression.html}{Regression} / \href{https://learningstatisticswithr.com/book/anova2.html}{Two-way ANOVA}\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright \textbf{Week 6}\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright \strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright August 9\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: \emph{t}-tests under the hood\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Inferential: Correlation under the hood\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright See relevant readings from previous weeks\strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright August 10\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: \(\chi^2\) under the hood\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Inferential: Regression under the hood\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \strut \end{minipage}\tabularnewline \begin{minipage}[t]{0.09\columnwidth}\raggedright August 11\strut \end{minipage} & \begin{minipage}[t]{0.32\columnwidth}\raggedright Inferential: ANOVA under the hood\strut \end{minipage} & \begin{minipage}[t]{0.29\columnwidth}\raggedright Advanced Topics / Review / Flex Day\strut \end{minipage} & \begin{minipage}[t]{0.18\columnwidth}\raggedright \strut \end{minipage}\tabularnewline \bottomrule \end{longtable} \hypertarget{policies}{% \section{Policies}\label{policies}} \hypertarget{attendance}{% \subsection{Attendance}\label{attendance}} Attendance is not required, but highly encouraged. We only meet for 6 weeks (a total of 17 classes), and classes build cumulatively off each other. If you are unable to attend class, all lectures will be recorded and made available on NYU Brightspace. \hypertarget{honor-code-and-plagarism}{% \subsection{Honor code and plagarism}\label{honor-code-and-plagarism}} No form of academic dishonesty will be tolerated. Suspicions of academic dishonesty during exams or on writing assignments will be reported to and adjudicated by the Associate Dean for Students. If a case of academic dishonesty is confirmed, it will result in a penalty that is at least as severe as receiving a 0 on the assignment or quiz. Academic dishonesty includes all forms of plagiarism. Plagiarism includes (but is not limited to): copying or paraphrasing from someone else's work (another student, an online source, or a journal article), turning in someone else's work as your own, or presenting someone else's ideas (a student, online source, or scholar) as your own. Most importantly, cheating only really serves to cheat yourself out of a learning opportunity. There are many opportunities to make up for a less-than-ideal grade, so don't let the possibility of a bad grade tempt you to cheat. We will do our best to make clear the line between academic dishonesty and collaborative learning. But if you have any questions about where this line is, it is your responsibility to ask the instructor. \hypertarget{accomodation}{% \subsection{Accomodation}\label{accomodation}} Any student requesting academic accommodations needs to notify the instructor before the third day of class. All discussions will remain confidential. Students with disabilities should also contact Disability Support Services in the \href{https://www.nyu.edu/students/communities-and-groups/student-accessibility.html}{Moses Center for Students with Disabilities}. \hypertarget{extra-help}{% \subsection{Extra Help}\label{extra-help}} If you start to struggle at any time during this course, please let us know as early as possible. We are happy to help and make accommodations (especially given the extraordinary circumstances!) but it's a lot easier to do so early on than it is to change things after the fact. If you come to us at the end of the class there may be very little we can do. The \href{https://www.nyu.edu/students/academic-services/undergraduate-advisement/academic-resource-center/tutoring-and-learning.html}{University Learning Center} has free peer tutoring and will be holding drop-in peer tutoring hours this summer, including weekly group session in support of statistics. Please see their website for their schedule. \hypertarget{late-assignments}{% \subsection{Late Assignments}\label{late-assignments}} Due to the condensed nature of this course, late assignments cannot be accepted. However, the nature of the grading for this course provides many opportunities to make up for missed assignments. You can miss up to 2 reflection `papers' and still receive full credit for participation. Similarly, only your highest final exam will count toward your grade. If you are unable to make an assignment deadline, please reach out to us before the assignment is due. However, if you are in the hospital with a serious illness, it's okay to reach out after the deadline when you feel a bit better (yes, this has happened, and I promise you your health and well-being is more important than this class). \hypertarget{religious-observances}{% \subsection{Religious observances}\label{religious-observances}} Some students may wish to take part in religious observances that occur during this academic term. If you have a religious observance which conflicts with your participation in the course, please meet with me by the end of the second week of the term to discuss appropriate accommodations. \hypertarget{pandemic-and-just-the-general-nature-of-life}{% \subsection{Pandemic and just the general nature of life}\label{pandemic-and-just-the-general-nature-of-life}} We are all going through difficult times during the pandemic. These include changes in our normal ways of doing things, living arrangements, family responsibilities, concerns about health and wellbeing, etc\ldots{} None of us is really OK all the time. If you tell me you're having trouble, I will not judge you or think less of you but will work with you to come up with a pathway forward. I hope you can extend me and the TA the same grace. You never owe me personal information about your health. You are always welcome to talk to me about things that you are going through. If I can't help you I might be able to direct you to someone who can. If you need extra help or need to miss a class or need more time please just ask. I will try to work with you. \bibliography{book.bib,packages.bib} \end{document}
[STATEMENT] lemma (in gcd_condition_monoid) gcd_divides_l: assumes "a \<in> carrier G" "b \<in> carrier G" shows "(somegcd G a b) divides a" [PROOF STATE] proof (prove) goal (1 subgoal): 1. somegcd G a b divides a [PROOF STEP] proof - [PROOF STATE] proof (state) goal (1 subgoal): 1. somegcd G a b divides a [PROOF STEP] interpret weak_lower_semilattice "division_rel G" [PROOF STATE] proof (prove) goal (1 subgoal): 1. weak_lower_semilattice (division_rel G) [PROOF STEP] by simp [PROOF STATE] proof (state) goal (1 subgoal): 1. somegcd G a b divides a [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. somegcd G a b divides a [PROOF STEP] by (metis assms gcd_isgcd isgcd_def) [PROOF STATE] proof (state) this: somegcd G a b divides a goal: No subgoals! [PROOF STEP] qed
[STATEMENT] lemma norm_form_uniq: assumes "cancels_to a b" and "cancels_to a c" and "canceled b" and "canceled c" shows "b = c" [PROOF STATE] proof (prove) goal (1 subgoal): 1. b = c [PROOF STEP] proof- [PROOF STATE] proof (state) goal (1 subgoal): 1. b = c [PROOF STEP] have "confluent cancels_to_1" [PROOF STATE] proof (prove) goal (1 subgoal): 1. confluent cancels_to_1 [PROOF STEP] by (rule confluent_cancels_to_1) [PROOF STATE] proof (state) this: confluent cancels_to_1 goal (1 subgoal): 1. b = c [PROOF STEP] moreover [PROOF STATE] proof (state) this: confluent cancels_to_1 goal (1 subgoal): 1. b = c [PROOF STEP] from \<open>cancels_to a b\<close> [PROOF STATE] proof (chain) picking this: cancels_to a b [PROOF STEP] have "cancels_to_1^** a b" [PROOF STATE] proof (prove) using this: cancels_to a b goal (1 subgoal): 1. cancels_to_1\<^sup>*\<^sup>* a b [PROOF STEP] by (simp add: cancels_to_def) [PROOF STATE] proof (state) this: cancels_to_1\<^sup>*\<^sup>* a b goal (1 subgoal): 1. b = c [PROOF STEP] moreover [PROOF STATE] proof (state) this: cancels_to_1\<^sup>*\<^sup>* a b goal (1 subgoal): 1. b = c [PROOF STEP] from \<open>cancels_to a c\<close> [PROOF STATE] proof (chain) picking this: cancels_to a c [PROOF STEP] have "cancels_to_1^** a c" [PROOF STATE] proof (prove) using this: cancels_to a c goal (1 subgoal): 1. cancels_to_1\<^sup>*\<^sup>* a c [PROOF STEP] by (simp add: cancels_to_def) [PROOF STATE] proof (state) this: cancels_to_1\<^sup>*\<^sup>* a c goal (1 subgoal): 1. b = c [PROOF STEP] moreover [PROOF STATE] proof (state) this: cancels_to_1\<^sup>*\<^sup>* a c goal (1 subgoal): 1. b = c [PROOF STEP] from \<open>canceled b\<close> [PROOF STATE] proof (chain) picking this: canceled b [PROOF STEP] have "\<not> Domainp cancels_to_1 b" [PROOF STATE] proof (prove) using this: canceled b goal (1 subgoal): 1. \<not> Domainp cancels_to_1 b [PROOF STEP] by (simp add: canceled_def) [PROOF STATE] proof (state) this: \<not> Domainp cancels_to_1 b goal (1 subgoal): 1. b = c [PROOF STEP] moreover [PROOF STATE] proof (state) this: \<not> Domainp cancels_to_1 b goal (1 subgoal): 1. b = c [PROOF STEP] from \<open>canceled c\<close> [PROOF STATE] proof (chain) picking this: canceled c [PROOF STEP] have "\<not> Domainp cancels_to_1 c" [PROOF STATE] proof (prove) using this: canceled c goal (1 subgoal): 1. \<not> Domainp cancels_to_1 c [PROOF STEP] by (simp add: canceled_def) [PROOF STATE] proof (state) this: \<not> Domainp cancels_to_1 c goal (1 subgoal): 1. b = c [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: confluent cancels_to_1 cancels_to_1\<^sup>*\<^sup>* a b cancels_to_1\<^sup>*\<^sup>* a c \<not> Domainp cancels_to_1 b \<not> Domainp cancels_to_1 c [PROOF STEP] show "b = c" [PROOF STATE] proof (prove) using this: confluent cancels_to_1 cancels_to_1\<^sup>*\<^sup>* a b cancels_to_1\<^sup>*\<^sup>* a c \<not> Domainp cancels_to_1 b \<not> Domainp cancels_to_1 c goal (1 subgoal): 1. b = c [PROOF STEP] by (rule confluent_unique_normal_form) [PROOF STATE] proof (state) this: b = c goal: No subgoals! [PROOF STEP] qed
using Logging using SeqLoggers using Test @testset "AdvancedLogger" begin file_name_pattern = raw"\a\c\c\e\s\s-YYYY-mm-dd-HH-MM.\l\o\g" dir_path = mktempdir() logger = AdvancedFileLogger(dir_path, file_name_pattern; min_level=Logging.Debug) with_logger(logger) do @debug "Log to file" @info "Log to file" @warn "Log to file" @error "Log to file" sleep(61) @info "Log to next file" A = 2 end log_files = joinpath.(dir_path, readdir(dir_path)) #kwarg join=true no in Julia 1.3 @test length(log_files) == 2 content = """[Debug] Log to file [Info] Log to file [Warning] Log to file [Error] Log to file """ @test log_files[1] |> read |> String == content @test_throws ArgumentError run_with_logger(logger) do @debug "Debug Log Message with 1 kwargs" keywarg="A" @info "Info Log Message with 2 kwargs" keywarg="A" second=rand(200, 10) third=DataFrame(rand(20,10)) @warn "Warn Log message without kwargs" @error "Error Log Before Exception" A="A" B="AB" C="ABC" D="ABCD" throw(ArgumentError("Throw an exception")) @info "After Exception" # Will not be excecuted end end @testset "Load AdvancedFileLogger" begin logging_config = Dict( "min_level" => "INFO", "dir_path" => "C:\\temp", "file_name_pattern" => "\\t\\e\\s\\t_YYYY-mm-dd.\\l\\o\\g", ) logger = SeqLoggers.load_advanced_filelogger(logging_config) @test logger.min_level == Logging.Info logging_config = Dict( "min_level" => "INFO", "dir_path" => "C:\\temp", "file_name_pattern" => "\\t\\e\\s\\t_YYYY-mm-dd.\\l\\o\\g", "transformation" => "add_timestamp", ) tran_logger = SeqLoggers.load_advanced_filelogger(logging_config) @test tran_logger.logger.min_level == Logging.Info end @testset "Load logger from config" begin config = Dict( "logging" => [ "SeqLogger" => Dict( "server_url" => "http://subdn215:5341/", "min_level" => "INFO", ), "ConsoleLogger" => Dict( "min_level" => "INFO", ), "FileLogger" => Dict( "min_level" => "INFO", "file_path" => raw"C:\Temp\test.txt", "append" => true, ), "AdvancedFileLogger" => Dict( "min_level" => "INFO", "dir_path" => "C:\\temp", "file_name_pattern" => "\\t\\e\\s\\t_YYYY-mm-dd.\\l\\o\\g", ) ] ) @test SeqLoggers.get_logger(config["logging"][4]...) isa MinLevelLogger # of FileLogger tee_logger = SeqLoggers.load_logger_from_config(config) @test tee_logger.loggers[4] isa MinLevelLogger # of FileLogger file_path = joinpath(@__DIR__, "data", "config_with_advanced_logger.json") tee_logger = SeqLoggers.load_logger_from_config(file_path) @test tee_logger.loggers[4] isa MinLevelLogger # of FileLogger end
# Logistic Regression Notebook version: 2.0 (Nov 21, 2017) 2.1 (Oct 19, 2018) 2.2 (Oct 09, 2019) 2.3 (Oct 27, 2020) Author: Jesús Cid Sueiro ([email protected]) Jerónimo Arenas García ([email protected]) Changes: v.1.0 - First version v.1.1 - Typo correction. Prepared for slide presentation v.2.0 - Prepared for Python 3.0 (backcompmatible with 2.7) Assumptions for regression model modified v.2.1 - Minor changes regarding notation and assumptions v.2.2 - Updated notation v.2.3 - Improved slides format. Backward compatibility removed ```python # To visualize plots in the notebook %matplotlib inline # Imported libraries import csv import random import matplotlib import matplotlib.pyplot as plt import pylab import numpy as np from mpl_toolkits.mplot3d import Axes3D from sklearn.preprocessing import PolynomialFeatures from sklearn import linear_model ``` ## 1. Introduction ### 1.1. Binary classification The **goal** of a classification problem is to assign a *class* or *category* to every *instance* or *observation* of a data collection. Here, we will assume that * every instance ${\bf x}$ is an $N$-dimensional vector in $\mathbb{R}^N$, and * the class $y$ of sample ${\bf x}$ is an element of a binary set ${\mathcal Y} = \{0, 1\}$. The goal of a classifier is to predict the true value of $y$ after observing ${\bf x}$. We will denote as $\hat{y}$ the classifier output or **decision**. If $y=\hat{y}$, the decision is a **hit**, otherwise $y\neq \hat{y}$ and the decision is an **error**. ### 1.2. Decision theory: the MAP criterion **Decision theory** provides a solution to the classification problem in situations where the relation between instance ${\bf x}$ and its class $y$ is given by a known probabilistic model. Assume that every tuple $({\bf x}, y)$ is an outcome of a random vector $({\bf X}, Y)$ with joint distribution $p_{{\bf X},Y}({\bf x}, y)$. A natural criteria for classification is to select predictor $\hat{Y}=f({\bf x})$ in such a way that the **probability or error**, $P\{\hat{Y} \neq Y\}$ is minimum. Noting that $$ P\{\hat{Y} \neq Y\} = \int P\{\hat{Y} \neq Y | {\bf x}\} p_{\bf X}({\bf x}) d{\bf x} $$ the optimal decision maker should take, for every sample ${\bf x}$, the decision minimizing the **conditional error probability**: \begin{align} \hat{y}^* &= \arg\min_{\hat{y}} P\{Y \neq \hat{y} |{\bf x}\} \\ &= \arg\max_{\hat{y}} P\{Y = \hat{y} |{\bf x}\} \\ \end{align} Thus, the **optimal decision rule** can be expressed as $$ P_{Y|{\bf X}}(1|{\bf x}) \quad\mathop{\gtrless}^{\hat{y}=1}_{\hat{y}=0}\quad P_{Y|{\bf X}}(0|{\bf x}) $$ or, equivalently $$ P_{Y|{\bf X}}(1|{\bf x}) \quad\mathop{\gtrless}^{\hat{y}=1}_{\hat{y}=0}\quad \frac{1}{2} $$ The classifier implementing this decision rule is usually referred to as the MAP (*Maximum A Posteriori*) classifier. As we have seen, the MAP classifier minimizes the error probability for binary classification, but the result can also be generalized to multiclass classification problems. ### 1.3. Learning **Classical decision theory** is grounded on the assumption that the probabilistic model relating the observed sample ${\bf X}$ and the true hypothesis $Y$ is known. Unfortunately, this is unrealistic in many applications, where the only available information to construct the classifier is a **dataset** $\mathcal D = \{{\bf x}_k, y_k\}_{k=0}^{K-1}$ of instances and their respective class labels. A more realistic formulation of the classification problem is the following: given a dataset $\mathcal D = \{({\bf x}_k, y_k) \in {\mathbb{R}}^N \times {\mathcal Y}, \, k=0,\ldots,{K-1}\}$ of independent and identically distributed (i.i.d.) samples from an ***unknown*** distribution $p_{{\bf X},Y}({\bf x}, y)$, predict the class $y$ of a new sample ${\bf x}$ with the minimum probability of error. ### 1.4. Parametric classifiers Since the probabilistic model generating the data is unknown, the MAP decision rule cannot be applied. However, we can use the dataset to **estimate the a posterior class probability model**, and apply it to approximate the MAP decision maker. **Parametric classifiers** based on this idea assume, additionally, that the posterior class probabilty satisfies some parametric formula: $$ P_{Y|X}(1|{\bf x},{\bf w}) = f_{\bf w}({\bf x}) $$ where ${\bf w}$ is a vector of parameters. Given the expression of the MAP decision maker, classification consists in comparing the value of $f_{\bf w}({\bf x})$ with the threshold $\frac{1}{2}$, and each parameter vector would be associated to a different decision maker. In practice, the dataset ${\mathcal D}$ is used to select a particular parameter vector $\hat{\bf w}$ according to certain criterion. Accordingly, the decision rule becomes $$ f_{\hat{\bf w}}({\bf x}) \quad\mathop{\gtrless}^{\hat{y}=1}_{\hat{y}=0}\quad \frac{1}{2} $$ In this notebook, we explore one of the most popular model-based parametric classification methods: **logistic regression**. ## 2. Logistic regression. ### 2.1. The logistic function The **logistic regression model** assumes that the binary class label $Y \in \{0,1\}$ of observation $X\in \mathbb{R}^N$ satisfies the expression. $$P_{Y|{\bf X}}(1|{\bf x}, {\bf w}) = g({\bf w}^\intercal{\bf x})$$ $$P_{Y|{\bf,X}}(0|{\bf x}, {\bf w}) = 1-g({\bf w}^\intercal{\bf x})$$ where ${\bf w}$ is a parameter vector and $g(·)$ is the **logistic** function, which is defined by $$g(t) = \frac{1}{1+\exp(-t)}$$ The code below defines and plots the logistic function: ```python # Define the logistic function def logistic(t): #<SOL> #</SOL> # Plot the logistic function t = np.arange(-6, 6, 0.1) z = logistic(t) plt.plot(t, z) plt.xlabel('$t$', fontsize=14) plt.ylabel('$g(t)$', fontsize=14) plt.title('The logistic function') plt.grid() ``` It is straightforward to see that the logistic function has the following properties: - **P1**: Probabilistic output: $\quad 0 \le g(t) \le 1$ - **P2**: Symmetry: $\quad g(-t) = 1-g(t)$ - **P3**: Monotonicity: $\quad g'(t) = g(t)\cdot [1-g(t)] \ge 0$ **Exercise 1**: Verify properties P2 and P3. **Exercise 2**: Implement a function to compute the logistic function, and use it to plot such function in the inverval $[-6,6]$. ### 2.2. Classifiers based on the logistic model. The MAP classifier under a logistic model will have the form $$P_{Y|{\bf X}}(1|{\bf x}, {\bf w}) = g({\bf w}^\intercal{\bf x}) \quad\mathop{\gtrless}^{\hat{y}=1}_{\hat{y}=0} \quad \frac{1}{2} $$ Therefore $$ 2 \quad\mathop{\gtrless}^{\hat{y}=1}_{\hat{y}=0} \quad 1 + \exp(-{\bf w}^\intercal{\bf x}) $$ which is equivalent to $${\bf w}^\intercal{\bf x} \quad\mathop{\gtrless}^{\hat{y}=1}_{\hat{y}=0}\quad 0 $$ Thus, the classifiers based on the logistic model are given by **linear decision boundaries** passing through the origin, ${\bf x} = {\bf 0}$. ```python # Weight vector: w = [4, 8] # Try different weights # Create a rectangular grid. x_min = -1 x_max = 1 h = (x_max - x_min) / 200 xgrid = np.arange(x_min, x_max, h) xx0, xx1 = np.meshgrid(xgrid, xgrid) # Compute the logistic map for the given weights, and plot Z = logistic(w[0]*xx0 + w[1]*xx1) fig = plt.figure() ax = fig.gca(projection='3d') ax.plot_surface(xx0, xx1, Z, cmap=plt.cm.copper) ax.contour(xx0, xx1, Z, levels=[0.5], colors='b', linewidths=(3,)) plt.xlabel('$x_0$') plt.ylabel('$x_1$') ax.set_zlabel('P(1|x,w)') plt.show() ``` The next code fragment represents the output of the same classifier, representing the output of the logistic function in the $x_0$-$x_1$ plane, encoding the value of the logistic function in the color map. ```python CS = plt.contourf(xx0, xx1, Z) CS2 = plt.contour(CS, levels=[0.5], colors='m', linewidths=(3,)) plt.xlabel('$x_0$') plt.ylabel('$x_1$') plt.colorbar(CS, ticks=[0, 0.5, 1]) plt.show() ``` ### 3.3. Nonlinear classifiers. The logistic model can be extended to construct non-linear classifiers by using **non-linear data transformations**. A general form for a nonlinear logistic regression model is $$P_{Y|{\bf X}}(1|{\bf x}, {\bf w}) = g[{\bf w}^\intercal{\bf z}({\bf x})] $$ where ${\bf z}({\bf x})$ is an arbitrary nonlinear transformation of the original variables. The boundary decision in that case is given by equation $$ {\bf w}^\intercal{\bf z} = 0 $$ **Exercise 3**: Modify the code above to generate a 3D surface plot of the polynomial logistic regression model given by $$ P_{Y|{\bf X}}(1|{\bf x}, {\bf w}) = g(1 + 10 x_0 + 10 x_1 - 20 x_0^2 + 5 x_0 x_1 + x_1^2) $$ ```python # Weight vector: w = [1, 10, 10, -20, 5, 1] # Try different weights # Create a regtangular grid. x_min = -1 x_max = 1 h = (x_max - x_min) / 200 xgrid = np.arange(x_min, x_max, h) xx0, xx1 = np.meshgrid(xgrid, xgrid) # Compute the logistic map for the given weights # Z = <FILL IN> # Plot the logistic map fig = plt.figure() ax = fig.gca(projection='3d') ax.plot_surface(xx0, xx1, Z, cmap=plt.cm.copper) plt.xlabel('$x_0$') plt.ylabel('$x_1$') ax.set_zlabel('P(1|x,w)') plt.show() ``` ```python CS = plt.contourf(xx0, xx1, Z) CS2 = plt.contour(CS, levels=[0.5], colors='m', linewidths=(3,)) plt.xlabel('$x_0$') plt.ylabel('$x_1$') plt.colorbar(CS, ticks=[0, 0.5, 1]) plt.show() ``` ## 3. Inference Remember that the idea of parametric classification is to use the training data set $\mathcal D = \{({\bf x}_k, y_k) \in {\mathbb{R}}^N \times \{0,1\}, k=0,\ldots,{K-1}\}$ to estimate ${\bf w}$. The estimate, $\hat{\bf w}$, can be used to compute the label prediction for any new observation as $$\hat{y} = \arg\max_y P_{Y|{\bf X}}(y|{\bf x},\hat{\bf w}).$$ In this notebook, we will discuss two different approaches to the estimation of ${\bf w}$: * **Maximum Likelihood** (ML): $\hat{\bf w}_{\text{ML}} = \arg\max_{\bf w} P_{{\mathcal D}|{\bf W}}({\mathcal D}|{\bf w})$ * **Maximum *A Posteriori** (MAP): $\hat{\bf w}_{\text{MAP}} = \arg\max_{\bf w} p_{{\bf W}|{\mathcal D}}({\bf w}|{\mathcal D})$ For the mathematical derivation of the logistic regression algorithm, the following representation of the logistic model will be useful: using the **symmetry** property of the logistic function, we can write $$P_{Y|{\bf X}}(0|{\bf x}, {\bf w}) = 1-g\left({\bf w}^\intercal{\bf z}({\bf x})\right) = g\left(-{\bf w}^\intercal{\bf z}({\bf x})\right)$$ thus $$P_{Y|{\bf X}}(y|{\bf x}, {\bf w}) = g\left(\overline{y}{\bf w}^\intercal{\bf z}({\bf x})\right)$$ where $\overline{y} = 2y-1$ is a **symmetrized label** ($\overline{y}\in\{-1, 1\}$). ### 3.1. Model assumptions In the following, we will make the following assumptions: - **A1**. (Logistic Regression): We assume a logistic model for the *a posteriori* probability of ${Y}$ given ${\bf X}$, i.e., $$P_{Y|{\bf X}}(y|{\bf x}, {\bf w}) = g\left({\bar y}\cdot {\bf w}^\intercal{\bf z}({\bf x})\right).$$ - **A2**. All samples in ${\mathcal D}$ have been generated from the same distribution, $p_{{\bf X}, Y| {\bf W}}({\bf x}, y| {\bf w})$. - **A3**. Input variables $\bf x$ do not depend on $\bf w$. This implies that $p({\bf x}|{\bf w}) = p({\bf x})$ - **A4**. Targets $y_0, \cdots, y_{K-1}$ are statistically independent given $\bf w$ and the inputs ${\bf x}_0, \cdots, {\bf x}_{K-1}$, that is: $$P(y_0, \cdots, y_{K-1} | {\bf x}_0, \cdots, {\bf x}_{K-1}, {\bf w}) = \prod_{k=0}^{K-1} P(y_k | {\bf x}_k, {\bf w})$$ ### 3.2. ML estimation. The ML estimate is defined as $$\hat{\bf w}_{\text{ML}} = \arg\max_{\bf w} P_{{\mathcal D}|{\bf W}}({\mathcal D}|{\bf w})$$ Ussing assumptions A2 and A3 above, we have that \begin{align} P_{{\mathcal D}|{\bf W}}({\mathcal D}|{\bf w}) & = p(y_0, \cdots, y_{K-1},{\bf x}_0, \cdots, {\bf x}_{K-1}| {\bf w}) \\ & = P(y_0, \cdots, y_{K-1}|{\bf x}_0, \cdots, {\bf x}_{K-1}, {\bf w}) \; p({\bf x}_0, \cdots, {\bf x}_{K-1}| {\bf w}) \\ & = P(y_0, \cdots, y_{K-1}|{\bf x}_0, \cdots, {\bf x}_{K-1}, {\bf w}) \; p({\bf x}_0, \cdots, {\bf x}_{K-1})\end{align} Finally, using assumption A4, we can formulate the ML estimation of $\bf w$ as the resolution of the following **optimization problem** \begin{align} \hat {\bf w}_\text{ML} & = \arg \max_{\bf w} P(y_0, \cdots, y_{K-1}|{\bf x}_0, \cdots, {\bf x}_{K-1}, {\bf w}) \\ & = \arg \max_{\bf w} \prod_{k=0}^{K-1} P(y_k|{\bf x}_k, {\bf w}) \\ & = \arg \max_{\bf w} \sum_{k=0}^{K-1} \log P(y_k|{\bf x}_k, {\bf w}) \\ & = \arg \min_{\bf w} \sum_{k=0}^{K-1} - \log P(y_k|{\bf x}_k, {\bf w}) \end{align} where the arguments of the maximization or minimization problems of the last three lines are usually referred to as the **likelihood**, **log-likelihood** $\left[L(\bf w)\right]$, and **negative log-likelihood** $\left[\text{NLL}(\bf w)\right]$, respectively. Now, using A1 (the logistic model) \begin{align} \text{NLL}({\bf w}) &= - \sum_{k=0}^{K-1}\log\left[g\left(\overline{y}_k{\bf w}^\intercal {\bf z}_k\right)\right] \\ &= \sum_{k=0}^{K-1}\log\left[1+\exp\left(-\overline{y}_k{\bf w}^\intercal {\bf z}_k\right)\right] \end{align} where ${\bf z}_k={\bf z}({\bf x}_k)$. It can be shown that $\text{NLL}({\bf w})$ is a **convex** and **differentiable** function of ${\bf w}$. Therefore, its minimum is a point with zero gradient. \begin{align} \nabla_{\bf w} \text{NLL}(\hat{\bf w}_{\text{ML}}) &= - \sum_{k=0}^{K-1} \frac{\exp\left(-\overline{y}_k\hat{\bf w}_{\text{ML}}^\intercal {\bf z}_k\right) \overline{y}_k {\bf z}_k} {1+\exp\left(-\overline{y}_k\hat{\bf w}_{\text{ML}}^\intercal {\bf z}_k \right)} = \\ &= - \sum_{k=0}^{K-1} \left[y_k-g(\hat{\bf w}_{\text{ML}}^T {\bf z}_k)\right] {\bf z}_k = 0 \end{align} Unfortunately, $\hat{\bf w}_{\text{ML}}$ cannot be taken out from the above equation, and some iterative optimization algorithm must be used to search for the minimum. ### 3.3. Gradient descent. A simple iterative optimization algorithm is <a href = https://en.wikipedia.org/wiki/Gradient_descent> gradient descent</a>. \begin{align} {\bf w}_{n+1} = {\bf w}_n - \rho_n \nabla_{\bf w} \text{NLL}({\bf w}_n) \end{align} where $\rho_n >0$ is the *learning step*. Applying the gradient descent rule to logistic regression, we get the following algorithm: \begin{align} {\bf w}_{n+1} &= {\bf w}_n + \rho_n \sum_{k=0}^{K-1} \left[y_k-g({\bf w}_n^\intercal {\bf z}_k)\right] {\bf z}_k \end{align} #### Gradient descent in matrix form Defining vectors \begin{align} {\bf y} &= [y_0,\ldots,y_{K-1}]^\top \\ \hat{\bf p}_n &= [g({\bf w}_n^\top {\bf z}_0), \ldots, g({\bf w}_n^\top {\bf z}_{K-1})]^\top \end{align} and matrix \begin{align} {\bf Z} = \left[{\bf z}_0,\ldots,{\bf z}_{K-1}\right]^\top \end{align} we can write \begin{align} {\bf w}_{n+1} &= {\bf w}_n + \rho_n {\bf Z}^\top \left({\bf y}-\hat{\bf p}_n\right) \end{align} In the following, we will explore the behavior of the gradient descend method using the Iris Dataset. ```python # Adapted from a notebook by Jason Brownlee def loadDataset(filename, split): xTrain, cTrain, xTest, cTest = [], [], [], [] with open(filename, 'r') as csvfile: lines = csv.reader(csvfile) dataset = list(lines) for i in range(len(dataset)-1): for y in range(4): dataset[i][y] = float(dataset[i][y]) item = dataset[i] if random.random() < split: xTrain.append(item[0:4]) cTrain.append(item[4]) else: xTest.append(item[0:4]) cTest.append(item[4]) return xTrain, cTrain, xTest, cTest xTrain_all, cTrain_all, xTest_all, cTest_all = loadDataset('iris.data', 0.66) nTrain_all = len(xTrain_all) nTest_all = len(xTest_all) print('Train:', nTrain_all) print('Test:', nTest_all) ``` Now, we select two classes and two attributes. ```python # Select attributes i = 0 # Try 0,1,2,3 j = 1 # Try 0,1,2,3 with j!=i # Select two classes c0 = 'Iris-versicolor' c1 = 'Iris-virginica' # Select two coordinates ind = [i, j] # Take training test X_tr = np.array([[xTrain_all[n][i] for i in ind] for n in range(nTrain_all) if cTrain_all[n]==c0 or cTrain_all[n]==c1]) C_tr = [cTrain_all[n] for n in range(nTrain_all) if cTrain_all[n]==c0 or cTrain_all[n]==c1] Y_tr = np.array([int(c==c1) for c in C_tr]) n_tr = len(X_tr) # Take test set X_tst = np.array([[xTest_all[n][i] for i in ind] for n in range(nTest_all) if cTest_all[n]==c0 or cTest_all[n]==c1]) C_tst = [cTest_all[n] for n in range(nTest_all) if cTest_all[n]==c0 or cTest_all[n]==c1] Y_tst = np.array([int(c==c1) for c in C_tst]) n_tst = len(X_tst) ``` #### 3.2.2. Data normalization Normalization of data is a common pre-processing step in many machine learning algorithms. Its goal is to get a dataset where all input coordinates have a similar scale. Learning algorithms usually show less instabilities and convergence problems when data are normalized. We will define a normalization function that returns a training data matrix with zero sample mean and unit sample variance. ```python def normalize(X, mx=None, sx=None): # Compute means and standard deviations if mx is None: mx = np.mean(X, axis=0) if sx is None: sx = np.std(X, axis=0) # Normalize X0 = (X-mx)/sx return X0, mx, sx ``` Now, we can normalize training and test data. Observe in the code that **the same transformation should be applied to training and test data**. This is the reason why normalization with the test data is done using the means and the variances computed with the training set. ```python # Normalize data Xn_tr, mx, sx = normalize(X_tr) Xn_tst, mx, sx = normalize(X_tst, mx, sx) ``` The following figure generates a plot of the normalized training data. ```python # Separate components of x into different arrays (just for the plots) x0c0 = [Xn_tr[n][0] for n in range(n_tr) if Y_tr[n]==0] x1c0 = [Xn_tr[n][1] for n in range(n_tr) if Y_tr[n]==0] x0c1 = [Xn_tr[n][0] for n in range(n_tr) if Y_tr[n]==1] x1c1 = [Xn_tr[n][1] for n in range(n_tr) if Y_tr[n]==1] # Scatterplot. labels = {'Iris-setosa': 'Setosa', 'Iris-versicolor': 'Versicolor', 'Iris-virginica': 'Virginica'} plt.plot(x0c0, x1c0,'r.', label=labels[c0]) plt.plot(x0c1, x1c1,'g+', label=labels[c1]) plt.xlabel('$x_' + str(ind[0]) + '$') plt.ylabel('$x_' + str(ind[1]) + '$') plt.legend(loc='best') plt.axis('equal') plt.show() ``` In order to apply the gradient descent rule, we need to define two methods: - A `fit` method, that receives the training data and returns the model weights and the value of the negative log-likelihood during all iterations. - A `predict` method, that receives the model weight and a set of inputs, and returns the posterior class probabilities for that input, as well as their corresponding class predictions. ```python def logregFit(Z_tr, Y_tr, rho, n_it): # Data dimension n_dim = Z_tr.shape[1] # Initialize variables nll_tr = np.zeros(n_it) pe_tr = np.zeros(n_it) Y_tr2 = 2*Y_tr - 1 # Transform labels into binary symmetric. w = np.random.randn(n_dim,1) # Running the gradient descent algorithm for n in range(n_it): # Compute posterior probabilities for weight w p1_tr = logistic(np.dot(Z_tr, w)) # Compute negative log-likelihood # (note that this is not required for the weight update, only for nll tracking) nll_tr[n] = np.sum(np.log(1 + np.exp(-np.dot(Y_tr2*Z_tr, w)))) # Update weights w += rho*np.dot(Z_tr.T, Y_tr - p1_tr) return w, nll_tr def logregPredict(Z, w): # Compute posterior probability of class 1 for weights w. p = logistic(np.dot(Z, w)).flatten() # Class D = [int(round(pn)) for pn in p] return p, D ``` We can test the behavior of the gradient descent method by fitting a logistic regression model with ${\bf z}({\bf x}) = (1, {\bf x}^\top)^\top$. ```python # Parameters of the algorithms rho = float(1)/50 # Learning step n_it = 200 # Number of iterations # Compute Z's Z_tr = np.c_[np.ones(n_tr), Xn_tr] Z_tst = np.c_[np.ones(n_tst), Xn_tst] n_dim = Z_tr.shape[1] # Convert target arrays to column vectors Y_tr2 = Y_tr[np.newaxis].T Y_tst2 = Y_tst[np.newaxis].T # Running the gradient descent algorithm w, nll_tr = logregFit(Z_tr, Y_tr2, rho, n_it) # Classify training and test data p_tr, D_tr = logregPredict(Z_tr, w) p_tst, D_tst = logregPredict(Z_tst, w) # Compute error rates E_tr = D_tr!=Y_tr E_tst = D_tst!=Y_tst # Error rates pe_tr = float(sum(E_tr)) / n_tr pe_tst = float(sum(E_tst)) / n_tst ``` ```python # NLL plot. plt.plot(range(n_it), nll_tr,'b.:', label='Train') plt.xlabel('Iteration') plt.ylabel('Negative Log-Likelihood') plt.legend() print(f'The optimal weights are: {w}') print('The final error rates are:') print(f'- Training: {pe_tr}') print(f'- Test: {pe_tst}') print(f'The NLL after training is {nll_tr[len(nll_tr)-1]}') ``` #### 3.2.3. Free parameters Under certain conditions, the gradient descent method can be shown to converge asymptotically (i.e. as the number of iterations goes to infinity) to the ML estimate of the logistic model. However, in practice, the final estimate of the weights ${\bf w}$ depend on several factors: - Number of iterations - Initialization - Learning step **Exercise 4**: Visualize the variability of gradient descent caused by initializations. To do so, fix the number of iterations to 200 and the learning step, and execute the gradient descent 100 times, storing the training error rate of each execution. Plot the histogram of the error rate values. Note that you can do this exercise with a loop over the 100 executions, including the code in the previous code slide inside the loop, with some proper modifications. To plot a histogram of the values in array `p` with `n`bins, you can use `plt.hist(p, n)` ```python ``` ##### 3.2.3.1. Learning step The learning step, $\rho$, is a free parameter of the algorithm. Its choice is critical for the convergence of the algorithm. Too large values of $\rho$ make the algorithm diverge. For too small values, the convergence gets very slow and more iterations are required for a good convergence. **Exercise 5**: Observe the evolution of the negative log-likelihood with the number of iterations for different values of $\rho$. It is easy to check that, for large enough $\rho$, the gradient descent method does not converge. Can you estimate (through manual observation) an approximate value of $\rho$ stating a boundary between convergence and divergence? ```python ``` **Exercise 6**: In this exercise we explore the influence of the learning step more sistematically. Use the code in the previouse exercises to compute, for every value of $\rho$, the average error rate over 100 executions. Plot the average error rate vs. $\rho$. Note that you should explore the values of $\rho$ in a logarithmic scale. For instance, you can take $\rho = 1, \frac{1}{10}, \frac{1}{100}, \frac{1}{1000}, \ldots$ ```python ``` In practice, the selection of $\rho$ may be a matter of trial an error. Also there is some theoretical evidence that the learning step should decrease along time up to cero, and the sequence $\rho_n$ should satisfy two conditions: - C1: $\sum_{n=0}^{\infty} \rho_n^2 < \infty$ (decrease slowly) - C2: $\sum_{n=0}^{\infty} \rho_n = \infty$ (but not too slowly) For instance, we can take $\rho_n= \frac{1}{n}$. Another common choice is $\rho_n = \frac{\alpha}{1+\beta n}$ where $\alpha$ and $\beta$ are also free parameters that can be selected by trial and error with some heuristic method. #### 3.2.4. Visualizing the posterior map. We can also visualize the posterior probability map estimated by the logistic regression model for the estimated weights. ```python # Create a regtangular grid. x_min, x_max = Xn_tr[:, 0].min(), Xn_tr[:, 0].max() y_min, y_max = Xn_tr[:, 1].min(), Xn_tr[:, 1].max() dx = x_max - x_min dy = y_max - y_min h = dy /400 xx, yy = np.meshgrid(np.arange(x_min - 0.1 * dx, x_max + 0.1 * dx, h), np.arange(y_min - 0.1 * dx, y_max + 0.1 * dy, h)) X_grid = np.array([xx.ravel(), yy.ravel()]).T # Compute Z's Z_grid = np.c_[np.ones(X_grid.shape[0]), X_grid] # Compute the classifier output for all samples in the grid. pp, dd = logregPredict(Z_grid, w) ``` ```python # Paint output maps pylab.rcParams['figure.figsize'] = 6, 6 # Set figure size # Color plot plt.plot(x0c0, x1c0,'r.', label=labels[c0]) plt.plot(x0c1, x1c1,'g+', label=labels[c1]) plt.xlabel('$x_' + str(ind[0]) + '$') plt.ylabel('$x_' + str(ind[1]) + '$') plt.legend(loc='best') plt.axis('equal') pp = pp.reshape(xx.shape) CS = plt.contourf(xx, yy, pp, cmap=plt.cm.copper) plt.contour(xx, yy, pp, levels=[0.5], colors='b', linewidths=(3,)) plt.colorbar(CS, ticks=[0, 0.5, 1]) plt.show() ``` #### 3.2.5. Polynomial Logistic Regression The error rates of the logistic regression model can be potentially reduced by using polynomial transformations. To compute the polynomial transformation up to a given degree, we can use the `PolynomialFeatures` method in `sklearn.preprocessing`. ```python # Parameters of the algorithms rho = float(1)/50 # Learning step n_it = 500 # Number of iterations g = 5 # Degree of polynomial # Compute Z_tr poly = PolynomialFeatures(degree=g) Z_tr = poly.fit_transform(Xn_tr) # Normalize columns (this is useful to make algorithms more stable).) Zn, mz, sz = normalize(Z_tr[:,1:]) Z_tr = np.concatenate((np.ones((n_tr,1)), Zn), axis=1) # Compute Z_tst Z_tst = poly.fit_transform(Xn_tst) Zn, mz, sz = normalize(Z_tst[:,1:], mz, sz) Z_tst = np.concatenate((np.ones((n_tst,1)), Zn), axis=1) # Convert target arrays to column vectors Y_tr2 = Y_tr[np.newaxis].T Y_tst2 = Y_tst[np.newaxis].T # Running the gradient descent algorithm w, nll_tr = logregFit(Z_tr, Y_tr2, rho, n_it) # Classify training and test data p_tr, D_tr = logregPredict(Z_tr, w) p_tst, D_tst = logregPredict(Z_tst, w) # Compute error rates E_tr = D_tr!=Y_tr E_tst = D_tst!=Y_tst # Error rates pe_tr = float(sum(E_tr)) / n_tr pe_tst = float(sum(E_tst)) / n_tst ``` ```python # NLL plot. plt.plot(range(n_it), nll_tr,'b.:', label='Train') plt.xlabel('Iteration') plt.ylabel('Negative Log-Likelihood') plt.legend() print(f'The optimal weights are: {w.T}') print('The final error rates are:') print(f'- Training: {pe_tr} \n- Test: {pe_tst}') print('The NLL after training is', nll_tr[len(nll_tr)-1]) ``` Visualizing the posterior map we can se that the polynomial transformation produces nonlinear decision boundaries. ```python # Compute Z_grid Z_grid = poly.fit_transform(X_grid) Zn, mz, sz = normalize(Z_grid[:,1:], mz, sz) Z_grid = np.concatenate((np.ones((Z_grid.shape[0],1)), Zn), axis=1) # Compute the classifier output for all samples in the grid. pp, dd = logregPredict(Z_grid, w) pp = pp.reshape(xx.shape) ``` ```python # Paint output maps pylab.rcParams['figure.figsize'] = 6, 6 # Set figure size plt.plot(x0c0, x1c0,'r.', label=labels[c0]) plt.plot(x0c1, x1c1,'g+', label=labels[c1]) plt.xlabel('$x_' + str(ind[0]) + '$') plt.ylabel('$x_' + str(ind[1]) + '$') plt.axis('equal') plt.legend(loc='best') CS = plt.contourf(xx, yy, pp, cmap=plt.cm.copper) plt.contour(xx, yy, pp, levels=[0.5], colors='b', linewidths=(3,)) plt.colorbar(CS, ticks=[0, 0.5, 1]) plt.show() ``` ## 4. Regularization and MAP estimation. ### 4.1 MAP estimation An alternative to the ML estimation of the weights in logistic regression is Maximum A Posteriori estimation. Modelling the logistic regression weights as a random variable with prior distribution $p_{\bf W}({\bf w})$, the **MAP estimate** is defined as $$ \hat{\bf w}_{\text{MAP}} = \arg\max_{\bf w} p({\bf w}|{\mathcal D}) $$ The posterior density $p({\bf w}|{\mathcal D})$ is related to the likelihood function and the prior density of the weights, $p_{\bf W}({\bf w})$ through the **Bayes rule** $$ p({\bf w}|{\mathcal D}) = \frac{P\left({\mathcal D}|{\bf w}\right) \; p_{\bf W}({\bf w})} {p\left({\mathcal D}\right)} $$ In general, the denominator in this expression cannot be computed analytically. However, it is not required for MAP estimation because it does not depend on ${\bf w}$. Therefore, the MAP solution is given by \begin{align} \hat{\bf w}_{\text{MAP}} & = \arg\max_{\bf w} \left\{ P\left({\mathcal D}|{\bf w}\right) \; p_{\bf W}({\bf w}) \right\}\\ & = \arg\max_{\bf w} \left\{ L({\mathbf w}) + \log p_{\bf W}({\bf w})\right\} \\ & = \arg\min_{\bf w} \left\{ \text{NLL}({\mathbf w}) - \log p_{\bf W}({\bf w})\right\} \end{align} In the light of this expression, we can conclude that the MAP solution is affected by two terms: - The likelihood, which takes large values for parameter vectors $\bf w$ that fit well the training data (smaller $\text{NLL}$ values) - The prior distribution of weights $p_{\bf W}({\bf w})$, which expresses our *a priori* preference for some solutions. ### 4.2. Regularization Even though the prior distribution has a natural interpretation as a model of our knowledge about $p({\bf w})$ before observing the data, its choice is frequenty motivated by the need to avoid data **overfitting**. **Data overfitting** is a frequent problem in ML estimation when the dimension of ${\bf w}$ is much higher that the dimension of the input ${\bf x}$: the ML solution can be too adjusted to the training data, while the test error rate is large. In practice **we recur to prior distributions that take large values when $\|{\bf w}\|$ is small** (associated to smooth classification borders). This helps to improve **generalization**. In this way, the MAP criterion adds a **penalty term** to the ML objective, that penalizes parameter vectors for which the prior distribution of weights takes small values. In machine learning, the process of introducing penalty terms to avoid overfitting is usually named **regularization**. ### 4.3 MAP estimation with Gaussian prior If we assume that ${\bf W}$ follows a **zero-mean Gaussian** random variable with variance matrix $v{\bf I}$, $$ p_{\bf W}({\bf w}) = \frac{1}{(2\pi v)^{N/2}} \exp\left(-\frac{1}{2v}\|{\bf w}\|^2\right) $$ the **MAP estimate** becomes \begin{align} \hat{\bf w}_{\text{MAP}} &= \arg\min_{\bf w} \left\{\text{NLL}({\bf w}) + \frac{1}{C}\|{\bf w}\|^2 \right\} \end{align} where $C = 2v$. Note that the **regularization term** associated to the prior penalizes parameter vectors with large components. Parameter $C$ controls the regularizatin, and it is named the **inverse regularization strength**. Noting that $$\nabla_{\bf w}\left\{\text{NLL}({\bf w}) + \frac{1}{C}\|{\bf w}\|^2\right\} = - {\bf Z} \left({\bf y}-\hat{\bf p}_n\right) + \frac{2}{C}{\bf w}, $$ we obtain the following **gradient descent rule** for MAP estimation \begin{align} {\bf w}_{n+1} &= \left(1-\frac{2\rho_n}{C}\right){\bf w}_n + \rho_n {\bf Z} \left({\bf y}-\hat{\bf p}_n\right) \end{align} Note that the regularization term "pushes" the weights towards zero. ### 4.4 MAP estimation with Laplacian prior If we assume that ${\bf W}$ follows a multivariate zero-mean Laplacian distribution given by $$ p_{\bf W}({\bf w}) = \frac{1}{(2 C)^{N}} \exp\left(-\frac{1}{C}\|{\bf w}\|_1\right) $$ (where $\|{\bf w}\|=|w_1|+\ldots+|w_N|$ is the $L_1$ norm of ${\bf w}$), the MAP estimate becomes \begin{align} \hat{\bf w}_{\text{MAP}} &= \arg\min_{\bf w} \left\{\text{NLL}({\bf w}) + \frac{1}{C}\|{\bf w}\|_1 \right\} \end{align} Parameter $C$ is named the *inverse regularization strength*. **Exercise 7**: Derive the gradient descent rules for MAP estimation of the logistic regression weights with Laplacian prior. ```python ``` ## 5. Other optimization algorithms ### 5.1. Stochastic Gradient descent. Stochastic gradient descent (SGD) is based on the idea of using a single sample at each iteration of the learning algorithm. The SGD rule for ML logistic regression is \begin{align} {\bf w}_{n+1} &= {\bf w}_n + \rho_n {\bf z}_n \left(y_n-\hat{p}_n\right) \end{align} Once all samples in the training set have been applied, the algorith can continue by applying the training set several times. The computational cost of each iteration of SGD is much smaller than that of gradient descent, though it usually needs many more iterations to converge. **Exercise 8**: Modify logregFit to implement an algorithm that applies the SGD rule. ### 5.2. Newton's method Assume that the function to be minimized, $C({\bf w})$, can be approximated by its **second order Taylor series expansion** around ${\bf w}_0$ $$ C({\bf w}) \approx C({\bf w}_0) + \nabla_{\bf w}^\top C({\bf w}_0)({\bf w}-{\bf w}_0) + \frac{1}{2}({\bf w}-{\bf w}_0)^\top{\bf H}({\bf w}_0)({\bf w}-{\bf w}_0) $$ where ${\bf H}({\bf w})$ is the <a href=https://en.wikipedia.org/wiki/Hessian_matrix> **Hessian matrix**</a> of $C$ at ${\bf w}$. Taking the gradient of $C({\bf w})$, and setting the result to ${\bf 0}$, the minimum of C around ${\bf w}_0$ can be approximated as $$ {\bf w}^* = {\bf w}_0 - {\bf H}({\bf w}_0)^{-1} \nabla_{\bf w}^\top C({\bf w}_0) $$ Since the second order polynomial is only an approximation to $C$, ${\bf w}^*$ is only an approximation to the optimal weight vector, but we can expect ${\bf w}^*$ to be closer to the minimizer of $C$ than ${\bf w}_0$. Thus, we can repeat the process, computing a second order approximation around ${\bf w}^*$ and a new approximation to the minimizer. <a href=https://en.wikipedia.org/wiki/Newton%27s_method_in_optimization> **Newton's method**</a> is based on this idea. At each optimization step, the function to be minimized is approximated by a second order approximation using a Taylor series expansion around the current estimate. As a result, the learning rule becomes $$\hat{\bf w}_{n+1} = \hat{\bf w}_{n} - \rho_n {\bf H}({\bf w}_n)^{-1} \nabla_{{\bf w}}C({\bf w}_n) $$ #### 5.2.1. Example: MAP estimation with Gaussian prior. For instance, for the MAP estimate with Gaussian prior, the *Hessian* matrix becomes $$ {\bf H}({\bf w}) = \frac{2}{C}{\bf I} + \sum_{k=0}^{K-1} g({\bf w}^\top {\bf z}_k) \left[1-g({\bf w}^\top {\bf z}_k)\right]{\bf z}_k {\bf z}_k^\top $$ Defining diagonal matrix $$ {\mathbf S}({\bf w}) = \text{diag}\left[g({\bf w}^\top {\bf z}_k) \left(1-g({\bf w}^\top {\bf z}_k)\right)\right] $$ the Hessian matrix can be written in more compact form as $$ {\bf H}({\bf w}) = \frac{2}{C}{\bf I} + {\bf Z}^\top {\bf S}({\bf w}) {\bf Z} $$ Therefore, the Newton's algorithm for logistic regression becomes \begin{align} {\bf w}_{n+1} = {\bf w}_{n} + \rho_n \left(\frac{2}{C}{\bf I} + {\bf Z}^\top {\bf S}({\bf w}_{n}) {\bf Z} \right)^{-1} {\bf Z}^\top \left({\bf y}-\hat{\bf p}_n\right) \end{align} Some variants of the Newton method are implemented in the <a href="http://scikit-learn.org/stable/"> Scikit-learn </a> package. ```python def logregFit2(Z_tr, Y_tr, rho, n_it, C=1e4): # Compute Z's r = 2.0/C n_dim = Z_tr.shape[1] # Initialize variables nll_tr = np.zeros(n_it) pe_tr = np.zeros(n_it) w = np.random.randn(n_dim,1) # Running the gradient descent algorithm for n in range(n_it): p_tr = logistic(np.dot(Z_tr, w)) sk = np.multiply(p_tr, 1-p_tr) S = np.diag(np.ravel(sk.T)) # Compute negative log-likelihood nll_tr[n] = - np.dot(Y_tr.T, np.log(p_tr)) - np.dot((1-Y_tr).T, np.log(1-p_tr)) # Update weights invH = np.linalg.inv(r*np.identity(n_dim) + np.dot(Z_tr.T, np.dot(S, Z_tr))) w += rho*np.dot(invH, np.dot(Z_tr.T, Y_tr - p_tr)) return w, nll_tr ``` ```python # Parameters of the algorithms rho = float(1)/50 # Learning step n_it = 500 # Number of iterations C = 1000 g = 4 # Compute Z_tr poly = PolynomialFeatures(degree=g) Z_tr = poly.fit_transform(X_tr) # Normalize columns (this is useful to make algorithms more stable).) Zn, mz, sz = normalize(Z_tr[:,1:]) Z_tr = np.concatenate((np.ones((n_tr,1)), Zn), axis=1) # Compute Z_tst Z_tst = poly.fit_transform(X_tst) Zn, mz, sz = normalize(Z_tst[:,1:], mz, sz) Z_tst = np.concatenate((np.ones((n_tst,1)), Zn), axis=1) # Convert target arrays to column vectors Y_tr2 = Y_tr[np.newaxis].T Y_tst2 = Y_tst[np.newaxis].T # Running the gradient descent algorithm w, nll_tr = logregFit2(Z_tr, Y_tr2, rho, n_it, C) # Classify training and test data p_tr, D_tr = logregPredict(Z_tr, w) p_tst, D_tst = logregPredict(Z_tst, w) # Compute error rates E_tr = D_tr!=Y_tr E_tst = D_tst!=Y_tst # Error rates pe_tr = float(sum(E_tr)) / n_tr pe_tst = float(sum(E_tst)) / n_tst ``` ```python # NLL plot. plt.plot(range(n_it), nll_tr,'b.:', label='Train') plt.xlabel('Iteration') plt.ylabel('Negative Log-Likelihood') plt.legend() print('The final error rates are:') print('- Training:', str(pe_tr)) print('- Test:', str(pe_tst)) print('The NLL after training is:', str(nll_tr[len(nll_tr)-1])) ``` ## 6. Logistic regression in Scikit Learn. The <a href="http://scikit-learn.org/stable/"> scikit-learn </a> package includes an efficient implementation of <a href="http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html#sklearn.linear_model.LogisticRegression"> logistic regression</a>. To use it, we must first create a classifier object, specifying the parameters of the logistic regression algorithm. ```python # Create a logistic regression object. LogReg = linear_model.LogisticRegression(C=1.0) # Compute Z_tr poly = PolynomialFeatures(degree=g) Z_tr = poly.fit_transform(Xn_tr) # Normalize columns (this is useful to make algorithms more stable).) Zn, mz, sz = normalize(Z_tr[:,1:]) Z_tr = np.concatenate((np.ones((n_tr,1)), Zn), axis=1) # Compute Z_tst Z_tst = poly.fit_transform(Xn_tst) Zn, mz, sz = normalize(Z_tst[:,1:], mz, sz) Z_tst = np.concatenate((np.ones((n_tst,1)), Zn), axis=1) # Fit model to data. LogReg.fit(Z_tr, Y_tr) # Classify training and test data D_tr = LogReg.predict(Z_tr) D_tst = LogReg.predict(Z_tst) ``` ```python # Compute error rates E_tr = D_tr!=Y_tr E_tst = D_tst!=Y_tst # Error rates pe_tr = float(sum(E_tr)) / n_tr pe_tst = float(sum(E_tst)) / n_tst print('The final error rates are:') print('- Training:', str(pe_tr)) print('- Test:', str(pe_tst)) # Compute Z_grid Z_grid = poly.fit_transform(X_grid) n_grid = Z_grid.shape[0] Zn, mz, sz = normalize(Z_grid[:,1:], mz, sz) Z_grid = np.concatenate((np.ones((n_grid,1)), Zn), axis=1) ``` ```python # Compute the classifier output for all samples in the grid. dd = LogReg.predict(Z_grid) pp = LogReg.predict_proba(Z_grid)[:,1] pp = pp.reshape(xx.shape) # Paint output maps pylab.rcParams['figure.figsize'] = 6, 6 # Set figure size plt.plot(x0c0, x1c0,'r.', label=labels[c0]) plt.plot(x0c1, x1c1,'g+', label=labels[c1]) plt.xlabel('$x_' + str(ind[0]) + '$') plt.ylabel('$x_' + str(ind[1]) + '$') plt.axis('equal') plt.contourf(xx, yy, pp, cmap=plt.cm.copper) plt.legend(loc='best') plt.contour(xx, yy, pp, levels=[0.5], colors='b', linewidths=(3,)) plt.colorbar(CS, ticks=[0, 0.5, 1]) plt.show() ``` ```python ```
!*robodoc*u* tests/testABV ! NAME ! testABV ! SYNOPSIS !$Id: testABV.f90 526 2018-03-25 23:44:51Z mexas $ program testABV ! PURPOSE ! Scaling analysis of solidification and cleavage. ! MPI/IO and F2015 collectives are used. ! DESCRIPTION ! The model is defined by (1) the CA box size, (2) the mean ! grain size and (3) the spatial resolution. ! First need to call cgca_gdim, cgca_cadim to ! calculate all parameters of coarray space, including ! the number of nuclei. Then call solidification and then ! cleavage. ! The parameters are chosen to give the biggest model ! that can fit on a single XC40 node in Hazel Hen ! (HLRS, PRACE, Tier-0 system). ! Then strong scaling can be investigated, including pure ! computation, computation + IO, pure IO etc. for solidification ! and fracture simulations. ! NOTE ! AUTHOR ! Anton Shterenlikht ! COPYRIGHT ! See LICENSE ! USES ! cgca testaux ! USED BY ! Part of CGPACK test suite ! SOURCE use testaux implicit none logical( kind=ldef ), parameter :: yesdebug=.true., nodebug=.false., & periodicbc=.true., noperiodicbc=.false. ! specify the total number of cleavage propagation iterations, ! and the number of times the fracture array will be dumped along ! the way integer( kind=idef ), parameter :: & itot = 300_idef, & ! total cleavage iterations to do idmp = 10_idef ! number of dumps to do along the way real, parameter :: gigabyte=real(2**30), & ! cleavage stress on 100, 110, 111 planes for BCC, ! see the manual for derivation. scrit(3) = (/ 1.05e4, 1.25e4, 4.90e4 /) !integer :: ierr ! default integer needed for MPI integer( kind=idef ) :: iter, fiter, ir(3), img, nimgs, & ng, & ! number of grains in the whole model c(3) ! coarray dimensions integer( kind=iarr ), allocatable :: space(:,:,:,:) [:,:,:] integer( kind=ilrg ) :: icells, mcells real( kind=rdef ) :: & t(3,3), & ! stress tensor qual, & ! quality bsz0(3), & ! the given "box" size bsz(3), & ! updated "box" size dm, & ! mean grain size, linear dim, phys units lres, & ! linear resolution, cells per unit of length res ! resolutions, cells per grain real( kind=rdef ), allocatable :: grt(:,:,:)[:,:,:] logical( kind=ldef ) :: solid character(6) :: citer real :: time1, time2 !*********************************************************************72 ! first executable statement ! physical dimensions of the box, assume mm bsz0 = (/ 4.0, 5.0, 5.0 /) ! mean grain size, linear dimension, e.g. mean grain diameter, also mm dm = 1.0e-1 ! resolution res = 1.0e5 ! In this test set the number of images via the env var ! the code must be able to cope with any value >= 1. img = this_image() nimgs = num_images() ! do a check on image 1 if ( img .eq. 1 ) then ! print a banner call banner("ABV") ! print the parameter values call cgca_pdmp write (*,'(a,i0,a)') "running on ", nimgs, " images in a 3D grid" end if ! want to sync here to make sure the banner is ! printed before the rest. sync all ! each image calculates the coarray grid dimensions call cgca_gdim( nimgs, ir, qual ) ! calculate the resolution and the actual phys dimensions ! of the box ! subroutine cgca_cadim( bsz, res, dm, ir, c, lres, ng ) ! c - coarray sizes ! ir - coarray grid sizes bsz = bsz0 call cgca_cadim( bsz, res, dm, ir, c, lres, ng ) ! total number of cells in a coarray icells = int( c(1), kind=ilrg ) * & int( c(2), kind=ilrg ) * & int( c(3), kind=ilrg ) ! total number of cells in the model mcells = icells * int( nimgs, kind=ilrg ) if ( img .eq. 1 ) then write ( *, "(9(a,i0), g11.3, g11.3, 3(a,g11.3), a )" ) & "img: ", img , " nimgs: ", nimgs, " (", c(1) , & "," , c(2) , "," , c(3) , ")[", ir(1), & "," , ir(2), "," , ir(3), "] ", ng , & qual, lres, & " (", bsz(1), ",", bsz(2), ",", bsz(3), ")" write (*,'(a,i0,a)') "Each image has ",icells, " cells" write (*,'(a,i0,a)') "The model has ", mcells, " cells" end if ! allocate space coarray with two layers ! implicit sync all call cgca_as(1, c(1), 1, c(2), 1, c(3), 1, ir(1), 1, ir(2), 1, 2, space) ! initialise random number seed call cgca_irs( nodebug ) ! allocate rotation tensors call cgca_art( 1, ng, 1, ir(1), 1, ir(2), 1, grt ) ! initialise space space( :, :, :, cgca_state_type_grain ) = cgca_liquid_state space( :, :, :, cgca_state_type_frac ) = cgca_intact_state ! nuclei, sync all inside call cgca_nr( space, ng, nodebug ) ! assign rotation tensors, sync all inside call cgca_rt( grt ) ! solidify, implicit sync all inside !subroutine cgca_sld( coarray, periodicbc, iter, heartbeat, solid ) !call cgca_sld( space, noperiodicbc, 0, 10, solid ) ! subroutine cgca_sld3( coarray, iter, heartbeat, solid ) call cpu_time(time1) call cgca_sld3( space, 0, 10, solid ) call cpu_time(time2) if ( img .eq. 1 ) write (*,*) "time, s", time2-time1 ! Stop at solidification stop ! initiate grain boundaries call cgca_igb( space ) ! smoothen the GB, several iterations, sync needed ! halo exchange, following smoothing call cgca_gbs( space ) call cgca_hxi( space ) call cgca_gbs( space ) call cgca_hxi( space ) sync all ! update grain connectivity, local routine, no sync needed call cgca_gcu( space ) ! set a single crack nucleus in the centre of the x3=max(x3) face space( c(1)/2, c(2)/2, c(3), cgca_state_type_frac ) & [ ir(1)/2, ir(2)/2, ir(3) ] = cgca_clvg_state_100_edge ! all images start MPI, used only for I/O here, so ! no need to start earlier !call MPI_Init(ierr) if ( img .eq. 1 ) write (*,*) "dumping model to files" ! dump space arrays to files, only image 1 does it, all others ! wait at the barrier, hence sync needed call cgca_pswci( space, cgca_state_type_grain, "zg0.raw" ) call cgca_pswci( space, cgca_state_type_frac, "zf0.raw" ) call cgca_swci( space, cgca_state_type_grain, 10, "zg0-ser.raw" ) call cgca_swci( space, cgca_state_type_frac, 10, "zf0-ser.raw" ) if ( img .eq. 1) write (*,*) "finished dumping model to files" sync all ! set the stress tensor t = 0.0 t(1,1) = 1.0e6 t(2,2) = -1.0e6 ! number of cleavage iterations between file dumps fiter = itot/idmp ! propagate cleavage, sync inside, dump fracture arrays ! every certain number of increments. do iter = 1, idmp ! Propagate cleavage, sync inside ! Run for fiter iterations ! subroutine cgca_clvgp( coarray, rt, t, scrit, sub, gcus, ! periodicbc, iter, heartbeat, debug ) call cgca_clvgp( space, grt, t, scrit, cgca_clvgsd, cgca_gcupdn, & noperiodicbc, fiter, 10, yesdebug ) ! dump the fracture space array to files, only image 1 does it, ! all others wait at the barrier, hence sync needed. ! citer is the total number of cleavage fracture iterations, ! "c" for character date type. write ( citer, "(i0)" ) iter*fiter call cgca_pswci( space, cgca_state_type_frac, & "zf"//trim(citer)//".raw" ) call cgca_swci( space, cgca_state_type_frac, 10, & "zf"//trim(citer)//"-ser.raw" ) sync all if ( img .eq. 1 ) write (*,"(a)") & "Completed "//trim(citer)//" cleavage iterations" end do ! deallocate all arrays, implicit sync all. call cgca_ds( space ) call cgca_dgc call cgca_drt( grt ) ! terminate MPI !call MPI_Finalize(ierr) if ( img .eq. 1 ) write (*,*) "Test ABV completed sucessfully" end program testABV !*roboend*
roots := n -> List([0 .. n-1], k -> E(n)^k); r:=roots(7); # [ 1, E(7), E(7)^2, E(7)^3, E(7)^4, E(7)^5, E(7)^6 ] List(r, x -> x^7); # [ 1, 1, 1, 1, 1, 1, 1 ]
[STATEMENT] lemma Mp_Mp_pow_is_Mp: "n \<noteq> 0 \<Longrightarrow> p > 1 \<Longrightarrow> poly_mod.Mp p (poly_mod.Mp (p^n) f) = poly_mod.Mp p f" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<lbrakk>n \<noteq> 0; 1 < p\<rbrakk> \<Longrightarrow> poly_mod.Mp p (poly_mod.Mp (p ^ n) f) = poly_mod.Mp p f [PROOF STEP] using poly_mod_2.Mp_product_modulus poly_mod_2_def [PROOF STATE] proof (prove) using this: \<lbrakk>poly_mod_2 ?m; ?m' = ?m * ?k; 0 < ?k\<rbrakk> \<Longrightarrow> poly_mod.Mp ?m (poly_mod.Mp ?m' ?f) = poly_mod.Mp ?m ?f poly_mod_2 ?m \<equiv> 1 < ?m goal (1 subgoal): 1. \<lbrakk>n \<noteq> 0; 1 < p\<rbrakk> \<Longrightarrow> poly_mod.Mp p (poly_mod.Mp (p ^ n) f) = poly_mod.Mp p f [PROOF STEP] by(subst power_eq_if, auto)
[GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t ⊢ rootMultiplicity t (↑derivative p) = rootMultiplicity t p - 1 [PROOFSTEP] rcases eq_or_ne p 0 with (rfl | hp) [GOAL] case inl R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R t : R hpt : IsRoot 0 t ⊢ rootMultiplicity t (↑derivative 0) = rootMultiplicity t 0 - 1 [PROOFSTEP] simp [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 ⊢ rootMultiplicity t (↑derivative p) = rootMultiplicity t p - 1 [PROOFSTEP] nth_rw 1 [← p.divByMonic_mul_pow_rootMultiplicity_eq t] [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 ⊢ rootMultiplicity t (↑derivative (p /ₘ (X - ↑C t) ^ rootMultiplicity t p * (X - ↑C t) ^ rootMultiplicity t p)) = rootMultiplicity t p - 1 [PROOFSTEP] simp only [derivative_pow, derivative_mul, derivative_sub, derivative_X, derivative_C, sub_zero, mul_one] [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 ⊢ rootMultiplicity t (↑derivative (p /ₘ (X - ↑C t) ^ rootMultiplicity t p) * (X - ↑C t) ^ rootMultiplicity t p + p /ₘ (X - ↑C t) ^ rootMultiplicity t p * (↑C ↑(rootMultiplicity t p) * (X - ↑C t) ^ (rootMultiplicity t p - 1))) = rootMultiplicity t p - 1 [PROOFSTEP] set n := p.rootMultiplicity t - 1 [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 ⊢ rootMultiplicity t (↑derivative (p /ₘ (X - ↑C t) ^ rootMultiplicity t p) * (X - ↑C t) ^ rootMultiplicity t p + p /ₘ (X - ↑C t) ^ rootMultiplicity t p * (↑C ↑(rootMultiplicity t p) * (X - ↑C t) ^ n)) = n [PROOFSTEP] have hn : n + 1 = _ := tsub_add_cancel_of_le ((rootMultiplicity_pos hp).mpr hpt) [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p ⊢ rootMultiplicity t (↑derivative (p /ₘ (X - ↑C t) ^ rootMultiplicity t p) * (X - ↑C t) ^ rootMultiplicity t p + p /ₘ (X - ↑C t) ^ rootMultiplicity t p * (↑C ↑(rootMultiplicity t p) * (X - ↑C t) ^ n)) = n [PROOFSTEP] rw [← hn] [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p ⊢ rootMultiplicity t (↑derivative (p /ₘ (X - ↑C t) ^ (n + 1)) * (X - ↑C t) ^ (n + 1) + p /ₘ (X - ↑C t) ^ (n + 1) * (↑C ↑(n + 1) * (X - ↑C t) ^ n)) = n [PROOFSTEP] set q := p /ₘ (X - C t) ^ (n + 1) with _hq [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) ⊢ rootMultiplicity t (↑derivative q * (X - ↑C t) ^ (n + 1) + q * (↑C ↑(n + 1) * (X - ↑C t) ^ n)) = n [PROOFSTEP] convert_to rootMultiplicity t ((X - C t) ^ n * (derivative q * (X - C t) + q * C ↑(n + 1))) = n [GOAL] case h.e'_2 R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) ⊢ rootMultiplicity t (↑derivative q * (X - ↑C t) ^ (n + 1) + q * (↑C ↑(n + 1) * (X - ↑C t) ^ n)) = rootMultiplicity t ((X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1))) [PROOFSTEP] congr [GOAL] case h.e'_2.e_p R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) ⊢ ↑derivative q * (X - ↑C t) ^ (n + 1) + q * (↑C ↑(n + 1) * (X - ↑C t) ^ n) = (X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) [PROOFSTEP] rw [mul_add, mul_left_comm <| (X - C t) ^ n, ← pow_succ'] [GOAL] case h.e'_2.e_p R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) ⊢ ↑derivative q * (X - ↑C t) ^ (n + 1) + q * (↑C ↑(n + 1) * (X - ↑C t) ^ n) = ↑derivative q * (X - ↑C t) ^ (n + 1) + (X - ↑C t) ^ n * (q * ↑C ↑(n + 1)) [PROOFSTEP] congr 1 [GOAL] case h.e'_2.e_p.e_a R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) ⊢ q * (↑C ↑(n + 1) * (X - ↑C t) ^ n) = (X - ↑C t) ^ n * (q * ↑C ↑(n + 1)) [PROOFSTEP] rw [mul_left_comm <| (X - C t) ^ n, mul_comm <| (X - C t) ^ n] [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) ⊢ rootMultiplicity t ((X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1))) = n [PROOFSTEP] have h : eval t (derivative q * (X - C t) + q * C (R := R) ↑(n + 1)) ≠ 0 := by suffices eval t q * ↑(n + 1) ≠ 0 by simpa refine' mul_ne_zero _ (Nat.cast_ne_zero.mpr n.succ_ne_zero) convert eval_divByMonic_pow_rootMultiplicity_ne_zero t hp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) ⊢ eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0 [PROOFSTEP] suffices eval t q * ↑(n + 1) ≠ 0 by simpa [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) this : eval t q * ↑(n + 1) ≠ 0 ⊢ eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0 [PROOFSTEP] simpa [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) ⊢ eval t q * ↑(n + 1) ≠ 0 [PROOFSTEP] refine' mul_ne_zero _ (Nat.cast_ne_zero.mpr n.succ_ne_zero) [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) ⊢ eval t q ≠ 0 [PROOFSTEP] convert eval_divByMonic_pow_rootMultiplicity_ne_zero t hp [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) h : eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0 ⊢ rootMultiplicity t ((X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1))) = n [PROOFSTEP] rw [rootMultiplicity_mul, rootMultiplicity_X_sub_C_pow, rootMultiplicity_eq_zero h, add_zero] [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) h : eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0 ⊢ (X - ↑C t) ^ n * (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0 [PROOFSTEP] refine' mul_ne_zero (pow_ne_zero n <| X_sub_C_ne_zero t) _ [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) h : eval t (↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1)) ≠ 0 ⊢ ↑derivative q * (X - ↑C t) + q * ↑C ↑(n + 1) ≠ 0 [PROOFSTEP] contrapose! h [GOAL] case inr R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R hpt : IsRoot p t hp : p ≠ 0 n : ℕ := rootMultiplicity t p - 1 hn : n + 1 = rootMultiplicity t p q : R[X] := p /ₘ (X - ↑C t) ^ (n + 1) _hq : q = p /ₘ (X - ↑C t) ^ (n + 1) h : ↑derivative (p /ₘ (X - ↑C t) ^ (n + 1)) * (X - ↑C t) + p /ₘ (X - ↑C t) ^ (n + 1) * ↑C ↑(rootMultiplicity t p - 1 + 1) = 0 ⊢ eval t (↑derivative (p /ₘ (X - ↑C t) ^ (n + 1)) * (X - ↑C t) + p /ₘ (X - ↑C t) ^ (n + 1) * ↑C ↑(rootMultiplicity t p - 1 + 1)) = 0 [PROOFSTEP] rw [h, eval_zero] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R ⊢ rootMultiplicity t p - 1 ≤ rootMultiplicity t (↑derivative p) [PROOFSTEP] by_cases p.IsRoot t [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R ⊢ rootMultiplicity t p - 1 ≤ rootMultiplicity t (↑derivative p) [PROOFSTEP] by_cases p.IsRoot t [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R h : IsRoot p t ⊢ rootMultiplicity t p - 1 ≤ rootMultiplicity t (↑derivative p) [PROOFSTEP] exact (derivative_rootMultiplicity_of_root h).symm.le [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R h : ¬IsRoot p t ⊢ rootMultiplicity t p - 1 ≤ rootMultiplicity t (↑derivative p) [PROOFSTEP] rw [rootMultiplicity_eq_zero h, zero_tsub] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : CharZero R p : R[X] t : R h : ¬IsRoot p t ⊢ 0 ≤ rootMultiplicity t (↑derivative p) [PROOFSTEP] exact zero_le _ [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R p : R[X] ⊢ ↑C ↑(normUnit (leadingCoeff p)) * ↑C ↑(normUnit (leadingCoeff p))⁻¹ = 1 [PROOFSTEP] rw [← RingHom.map_mul, Units.mul_inv, C_1] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R p : R[X] ⊢ ↑C ↑(normUnit (leadingCoeff p))⁻¹ * ↑C ↑(normUnit (leadingCoeff p)) = 1 [PROOFSTEP] rw [← RingHom.map_mul, Units.inv_mul, C_1] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R ⊢ ↑((fun p => { val := ↑C ↑(normUnit (leadingCoeff p)), inv := ↑C ↑(normUnit (leadingCoeff p))⁻¹, val_inv := (_ : ↑C ↑(normUnit (leadingCoeff p)) * ↑C ↑(normUnit (leadingCoeff p))⁻¹ = 1), inv_val := (_ : ↑C ↑(normUnit (leadingCoeff p))⁻¹ * ↑C ↑(normUnit (leadingCoeff p)) = 1) }) 0) = ↑1 [PROOFSTEP] simp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R a✝ b✝ : R[X] hp0 : a✝ ≠ 0 hq0 : b✝ ≠ 0 ⊢ ↑((fun p => { val := ↑C ↑(normUnit (leadingCoeff p)), inv := ↑C ↑(normUnit (leadingCoeff p))⁻¹, val_inv := (_ : ↑C ↑(normUnit (leadingCoeff p)) * ↑C ↑(normUnit (leadingCoeff p))⁻¹ = 1), inv_val := (_ : ↑C ↑(normUnit (leadingCoeff p))⁻¹ * ↑C ↑(normUnit (leadingCoeff p)) = 1) }) (a✝ * b✝)) = ↑((fun p => { val := ↑C ↑(normUnit (leadingCoeff p)), inv := ↑C ↑(normUnit (leadingCoeff p))⁻¹, val_inv := (_ : ↑C ↑(normUnit (leadingCoeff p)) * ↑C ↑(normUnit (leadingCoeff p))⁻¹ = 1), inv_val := (_ : ↑C ↑(normUnit (leadingCoeff p))⁻¹ * ↑C ↑(normUnit (leadingCoeff p)) = 1) }) a✝ * (fun p => { val := ↑C ↑(normUnit (leadingCoeff p)), inv := ↑C ↑(normUnit (leadingCoeff p))⁻¹, val_inv := (_ : ↑C ↑(normUnit (leadingCoeff p)) * ↑C ↑(normUnit (leadingCoeff p))⁻¹ = 1), inv_val := (_ : ↑C ↑(normUnit (leadingCoeff p))⁻¹ * ↑C ↑(normUnit (leadingCoeff p)) = 1) }) b✝) [PROOFSTEP] dsimp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R a✝ b✝ : R[X] hp0 : a✝ ≠ 0 hq0 : b✝ ≠ 0 ⊢ ↑C ↑(normUnit (leadingCoeff (a✝ * b✝))) = ↑C ↑(normUnit (leadingCoeff a✝)) * ↑C ↑(normUnit (leadingCoeff b✝)) [PROOFSTEP] rw [Ne.def, ← leadingCoeff_eq_zero] at * [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R a✝ b✝ : R[X] hp0 : ¬leadingCoeff a✝ = 0 hq0 : ¬leadingCoeff b✝ = 0 ⊢ ↑C ↑(normUnit (leadingCoeff (a✝ * b✝))) = ↑C ↑(normUnit (leadingCoeff a✝)) * ↑C ↑(normUnit (leadingCoeff b✝)) [PROOFSTEP] rw [leadingCoeff_mul, normUnit_mul hp0 hq0, Units.val_mul, C_mul] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R u : R[X]ˣ ⊢ ↑((fun p => { val := ↑C ↑(normUnit (leadingCoeff p)), inv := ↑C ↑(normUnit (leadingCoeff p))⁻¹, val_inv := (_ : ↑C ↑(normUnit (leadingCoeff p)) * ↑C ↑(normUnit (leadingCoeff p))⁻¹ = 1), inv_val := (_ : ↑C ↑(normUnit (leadingCoeff p))⁻¹ * ↑C ↑(normUnit (leadingCoeff p)) = 1) }) ↑u) = ↑u⁻¹ [PROOFSTEP] dsimp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R u : R[X]ˣ ⊢ ↑C ↑(normUnit (leadingCoeff ↑u)) = ↑u⁻¹ [PROOFSTEP] rw [← mul_one u⁻¹, Units.val_mul, Units.eq_inv_mul_iff_mul_eq] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R u : R[X]ˣ ⊢ ↑u * ↑C ↑(normUnit (leadingCoeff ↑u)) = ↑1 [PROOFSTEP] rcases Polynomial.isUnit_iff.1 ⟨u, rfl⟩ with ⟨_, ⟨w, rfl⟩, h2⟩ [GOAL] case intro.intro.intro R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R u : R[X]ˣ w : Rˣ h2 : ↑C ↑w = ↑u ⊢ ↑u * ↑C ↑(normUnit (leadingCoeff ↑u)) = ↑1 [PROOFSTEP] rw [← h2, leadingCoeff_C, normUnit_coe_units, ← C_mul, Units.mul_inv, C_1] [GOAL] case intro.intro.intro R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R u : R[X]ˣ w : Rˣ h2 : ↑C ↑w = ↑u ⊢ 1 = ↑1 [PROOFSTEP] rfl [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R p : R[X] ⊢ ↑(normUnit p) = ↑C ↑(normUnit (leadingCoeff p)) [PROOFSTEP] simp [normUnit] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R p : R[X] ⊢ leadingCoeff (↑normalize p) = ↑normalize (leadingCoeff p) [PROOFSTEP] simp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R p : R[X] hp : Monic p ⊢ ↑normalize p = p [PROOFSTEP] simp only [Polynomial.coe_normUnit, normalize_apply, hp.leadingCoeff, normUnit_one, Units.val_one, Polynomial.C.map_one, mul_one] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : CommRing R inst✝¹ : IsDomain R inst✝ : NormalizationMonoid R p : R[X] ⊢ roots (↑normalize p) = roots p [PROOFSTEP] rw [normalize_apply, mul_comm, coe_normUnit, roots_C_mul _ (normUnit (leadingCoeff p)).ne_zero] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : DivisionRing R p q : R[X] hp0 : p ≠ 0 hp : ¬IsUnit p h : 0 ≥ degree p ⊢ False [PROOFSTEP] rw [eq_C_of_degree_le_zero h] at hp0 hp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : DivisionRing R p q : R[X] hp0 : ↑C (coeff p 0) ≠ 0 hp : ¬IsUnit (↑C (coeff p 0)) h : 0 ≥ degree p ⊢ False [PROOFSTEP] exact hp (IsUnit.map C (IsUnit.mk0 (coeff p 0) (mt C_inj.2 (by simpa using hp0)))) [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : DivisionRing R p q : R[X] hp0 : ↑C (coeff p 0) ≠ 0 hp : ¬IsUnit (↑C (coeff p 0)) h : 0 ≥ degree p ⊢ ¬↑C (coeff p 0) = ↑C 0 [PROOFSTEP] simpa using hp0 [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : DivisionRing R p q : R[X] h : p ≠ 0 ⊢ Monic (p * ↑C (leadingCoeff p)⁻¹) [PROOFSTEP] rw [Monic, leadingCoeff_mul, leadingCoeff_C, mul_inv_cancel (show leadingCoeff p ≠ 0 from mt leadingCoeff_eq_zero.1 h)] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : DivisionRing R p✝ q p : R[X] h : q ≠ 0 ⊢ degree (p * ↑C (leadingCoeff q)⁻¹) = degree p [PROOFSTEP] have h₁ : (leadingCoeff q)⁻¹ ≠ 0 := inv_ne_zero (mt leadingCoeff_eq_zero.1 h) [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : DivisionRing R p✝ q p : R[X] h : q ≠ 0 h₁ : (leadingCoeff q)⁻¹ ≠ 0 ⊢ degree (p * ↑C (leadingCoeff q)⁻¹) = degree p [PROOFSTEP] rw [degree_mul, degree_C h₁, add_zero] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : DivisionRing R p q : R[X] inst✝¹ : Semiring S inst✝ : Nontrivial S f : R →+* S ⊢ map f p = 0 ↔ p = 0 [PROOFSTEP] simp only [Polynomial.ext_iff] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : DivisionRing R p q : R[X] inst✝¹ : Semiring S inst✝ : Nontrivial S f : R →+* S ⊢ (∀ (n : ℕ), coeff (map f p) n = coeff 0 n) ↔ ∀ (n : ℕ), coeff p n = coeff 0 n [PROOFSTEP] congr! [GOAL] case a.h.a R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : DivisionRing R p q : R[X] inst✝¹ : Semiring S inst✝ : Nontrivial S f : R →+* S a✝ : ℕ ⊢ coeff (map f p) a✝ = coeff 0 a✝ ↔ coeff p a✝ = coeff 0 a✝ [PROOFSTEP] simp [map_eq_zero, coeff_map, coeff_zero] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : DivisionRing R p q : R[X] inst✝¹ : Semiring S inst✝ : Nontrivial S f : R →+* S ⊢ leadingCoeff (map f p) = ↑f (leadingCoeff p) [PROOFSTEP] simp only [← coeff_natDegree, coeff_map f, natDegree_map] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : DivisionRing R p✝ q : R[X] inst✝¹ : Semiring S inst✝ : Nontrivial S f : R →+* S p : R[X] ⊢ Monic (map f p) ↔ Monic p [PROOFSTEP] rw [Monic, leadingCoeff_map, ← f.map_one, Function.Injective.eq_iff f.injective, Monic] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 0 ⊢ degree p ≤ 0 [PROOFSTEP] simp [*, le_refl] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 0 this : degree p ≤ 0 hc : coeff p 0 = 0 ⊢ False [PROOFSTEP] rw [eq_C_of_degree_le_zero this, hc] at h [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree (↑C 0) = 0 this : degree p ≤ 0 hc : coeff p 0 = 0 ⊢ False [PROOFSTEP] simp at h [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 0 this : degree p ≤ 0 hc : coeff p 0 ≠ 0 ⊢ 1 = p * ↑C (coeff p 0)⁻¹ [PROOFSTEP] conv in p => rw [eq_C_of_degree_le_zero this] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 0 this : degree p ≤ 0 hc : coeff p 0 ≠ 0 | p [PROOFSTEP] rw [eq_C_of_degree_le_zero this] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 0 this : degree p ≤ 0 hc : coeff p 0 ≠ 0 | p [PROOFSTEP] rw [eq_C_of_degree_le_zero this] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 0 this : degree p ≤ 0 hc : coeff p 0 ≠ 0 | p [PROOFSTEP] rw [eq_C_of_degree_le_zero this] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 0 this : degree p ≤ 0 hc : coeff p 0 ≠ 0 ⊢ 1 = ↑C (coeff p 0) * ↑C (coeff p 0)⁻¹ [PROOFSTEP] rw [← C_mul, _root_.mul_inv_cancel hc, C_1] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] ⊢ q * div p q + mod p q = p [PROOFSTEP] by_cases h : q = 0 [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] h : q = 0 ⊢ q * div p q + mod p q = p [PROOFSTEP] simp only [h, zero_mul, mod, modByMonic_zero, zero_add] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] h : ¬q = 0 ⊢ q * div p q + mod p q = p [PROOFSTEP] conv => rhs rw [← modByMonic_add_div p (monic_mul_leadingCoeff_inv h)] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] h : ¬q = 0 | q * div p q + mod p q = p [PROOFSTEP] rhs rw [← modByMonic_add_div p (monic_mul_leadingCoeff_inv h)] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] h : ¬q = 0 | q * div p q + mod p q = p [PROOFSTEP] rhs rw [← modByMonic_add_div p (monic_mul_leadingCoeff_inv h)] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] h : ¬q = 0 | q * div p q + mod p q = p [PROOFSTEP] rhs [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] h : ¬q = 0 | p [PROOFSTEP] rw [← modByMonic_add_div p (monic_mul_leadingCoeff_inv h)] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] h : ¬q = 0 ⊢ q * div p q + mod p q = p %ₘ (q * ↑C (leadingCoeff q)⁻¹) + q * ↑C (leadingCoeff q)⁻¹ * (p /ₘ (q * ↑C (leadingCoeff q)⁻¹)) [PROOFSTEP] rw [div, mod, add_comm, mul_assoc] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q p : R[X] hq : q ≠ 0 ⊢ degree (mod p q) < degree q [PROOFSTEP] rw [← degree_mul_leadingCoeff_inv q hq] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q p : R[X] hq : q ≠ 0 ⊢ degree (mod p q) < degree (q * ↑C (leadingCoeff q)⁻¹) [PROOFSTEP] exact degree_modByMonic_lt p (monic_mul_leadingCoeff_inv hq) [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q p : R[X] hq : Monic q ⊢ p %ₘ q = p %ₘ (q * ↑C (leadingCoeff q)⁻¹) [PROOFSTEP] simp only [Monic.def.1 hq, inv_one, mul_one, C_1] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q p : R[X] hq : Monic q ⊢ p /ₘ q = ↑C (leadingCoeff q)⁻¹ * (p /ₘ (q * ↑C (leadingCoeff q)⁻¹)) [PROOFSTEP] simp only [Monic.def.1 hq, inv_one, C_1, one_mul, mul_one] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] src✝¹ : CommRing R[X] := commRing src✝ : Nontrivial R[X] := nontrivial ⊢ ∀ (a : R[X]), (fun x x_1 => x / x_1) a 0 = 0 [PROOFSTEP] simp [div_def] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q ⊢ p % q = p [PROOFSTEP] classical have : ¬degree (q * C (leadingCoeff q)⁻¹) ≤ degree p := not_le_of_gt <| by rwa [degree_mul_leadingCoeff_inv q hq0] rw [mod_def, modByMonic, dif_pos (monic_mul_leadingCoeff_inv hq0)] unfold divModByMonicAux dsimp simp only [this, false_and_iff, if_false] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q ⊢ p % q = p [PROOFSTEP] have : ¬degree (q * C (leadingCoeff q)⁻¹) ≤ degree p := not_le_of_gt <| by rwa [degree_mul_leadingCoeff_inv q hq0] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q ⊢ degree (q * ↑C (leadingCoeff q)⁻¹) > degree p [PROOFSTEP] rwa [degree_mul_leadingCoeff_inv q hq0] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q this : ¬degree (q * ↑C (leadingCoeff q)⁻¹) ≤ degree p ⊢ p % q = p [PROOFSTEP] rw [mod_def, modByMonic, dif_pos (monic_mul_leadingCoeff_inv hq0)] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q this : ¬degree (q * ↑C (leadingCoeff q)⁻¹) ≤ degree p ⊢ (divModByMonicAux p (_ : Monic (q * ↑C (leadingCoeff q)⁻¹))).snd = p [PROOFSTEP] unfold divModByMonicAux [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q this : ¬degree (q * ↑C (leadingCoeff q)⁻¹) ≤ degree p ⊢ (if h : degree (q * ↑C (leadingCoeff q)⁻¹) ≤ degree p ∧ p ≠ 0 then let z := ↑C (leadingCoeff p) * X ^ (natDegree p - natDegree (q * ↑C (leadingCoeff q)⁻¹)); let_fun _wf := (_ : degree (p - ↑C (leadingCoeff p) * X ^ (natDegree p - natDegree (q * ↑C (leadingCoeff q)⁻¹)) * (q * ↑C (leadingCoeff q)⁻¹)) < degree p); let dm := divModByMonicAux (p - z * (q * ↑C (leadingCoeff q)⁻¹)) (_ : Monic (q * ↑C (leadingCoeff q)⁻¹)); (z + dm.fst, dm.snd) else (0, p)).snd = p [PROOFSTEP] dsimp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q this : ¬degree (q * ↑C (leadingCoeff q)⁻¹) ≤ degree p ⊢ (if degree (q * ↑C (leadingCoeff q)⁻¹) ≤ degree p ∧ ¬p = 0 then (↑C (leadingCoeff p) * X ^ (natDegree p - natDegree (q * ↑C (leadingCoeff q)⁻¹)) + (divModByMonicAux (p - ↑C (leadingCoeff p) * X ^ (natDegree p - natDegree (q * ↑C (leadingCoeff q)⁻¹)) * (q * ↑C (leadingCoeff q)⁻¹)) (_ : Monic (q * ↑C (leadingCoeff q)⁻¹))).fst, (divModByMonicAux (p - ↑C (leadingCoeff p) * X ^ (natDegree p - natDegree (q * ↑C (leadingCoeff q)⁻¹)) * (q * ↑C (leadingCoeff q)⁻¹)) (_ : Monic (q * ↑C (leadingCoeff q)⁻¹))).snd) else (0, p)).snd = p [PROOFSTEP] simp only [this, false_and_iff, if_false] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : p / q = 0 ⊢ degree p < degree q [PROOFSTEP] have := EuclideanDomain.div_add_mod p q [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : p / q = 0 this : q * (p / q) + p % q = p ⊢ degree p < degree q [PROOFSTEP] rwa [h, mul_zero, zero_add, mod_eq_self_iff hq0] at this [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q ⊢ p / q = 0 [PROOFSTEP] have hlt : degree p < degree (q * C (leadingCoeff q)⁻¹) := by rwa [degree_mul_leadingCoeff_inv q hq0] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q ⊢ degree p < degree (q * ↑C (leadingCoeff q)⁻¹) [PROOFSTEP] rwa [degree_mul_leadingCoeff_inv q hq0] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q hlt : degree p < degree (q * ↑C (leadingCoeff q)⁻¹) ⊢ p / q = 0 [PROOFSTEP] have hm : Monic (q * C (leadingCoeff q)⁻¹) := monic_mul_leadingCoeff_inv hq0 [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 h : degree p < degree q hlt : degree p < degree (q * ↑C (leadingCoeff q)⁻¹) hm : Monic (q * ↑C (leadingCoeff q)⁻¹) ⊢ p / q = 0 [PROOFSTEP] rw [div_def, (divByMonic_eq_zero_iff hm).2 hlt, mul_zero] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 hpq : degree q ≤ degree p ⊢ degree q + degree (p / q) = degree p [PROOFSTEP] have : degree (p % q) < degree (q * (p / q)) := calc degree (p % q) < degree q := EuclideanDomain.mod_lt _ hq0 _ ≤ _ := degree_le_mul_left _ (mt (div_eq_zero_iff hq0).1 (not_lt_of_ge hpq)) [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 hpq : degree q ≤ degree p this : degree (p % q) < degree (q * (p / q)) ⊢ degree q + degree (p / q) = degree p [PROOFSTEP] conv_rhs => rw [← EuclideanDomain.div_add_mod p q, degree_add_eq_left_of_degree_lt this, degree_mul] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 hpq : degree q ≤ degree p this : degree (p % q) < degree (q * (p / q)) | degree p [PROOFSTEP] rw [← EuclideanDomain.div_add_mod p q, degree_add_eq_left_of_degree_lt this, degree_mul] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 hpq : degree q ≤ degree p this : degree (p % q) < degree (q * (p / q)) | degree p [PROOFSTEP] rw [← EuclideanDomain.div_add_mod p q, degree_add_eq_left_of_degree_lt this, degree_mul] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hq0 : q ≠ 0 hpq : degree q ≤ degree p this : degree (p % q) < degree (q * (p / q)) | degree p [PROOFSTEP] rw [← EuclideanDomain.div_add_mod p q, degree_add_eq_left_of_degree_lt this, degree_mul] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] ⊢ degree (p / q) ≤ degree p [PROOFSTEP] by_cases hq : q = 0 [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] hq : q = 0 ⊢ degree (p / q) ≤ degree p [PROOFSTEP] simp [hq] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] hq : ¬q = 0 ⊢ degree (p / q) ≤ degree p [PROOFSTEP] rw [div_def, mul_comm, degree_mul_leadingCoeff_inv _ hq] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p✝ q✝ p q : R[X] hq : ¬q = 0 ⊢ degree (p /ₘ (q * ↑C (leadingCoeff q)⁻¹)) ≤ degree p [PROOFSTEP] exact degree_divByMonic_le _ _ [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp : p ≠ 0 hq : 0 < degree q ⊢ degree (p / q) < degree p [PROOFSTEP] have hq0 : q ≠ 0 := fun hq0 => by simp [hq0] at hq [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp : p ≠ 0 hq : 0 < degree q hq0 : q = 0 ⊢ False [PROOFSTEP] simp [hq0] at hq [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp : p ≠ 0 hq : 0 < degree q hq0 : q ≠ 0 ⊢ degree (p / q) < degree p [PROOFSTEP] rw [div_def, mul_comm, degree_mul_leadingCoeff_inv _ hq0] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp : p ≠ 0 hq : 0 < degree q hq0 : q ≠ 0 ⊢ degree (p /ₘ (q * ↑C (leadingCoeff q)⁻¹)) < degree p [PROOFSTEP] exact degree_divByMonic_lt _ (monic_mul_leadingCoeff_inv hq0) hp (by rw [degree_mul_leadingCoeff_inv _ hq0]; exact hq) [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp : p ≠ 0 hq : 0 < degree q hq0 : q ≠ 0 ⊢ 0 < degree (q * ↑C (leadingCoeff q)⁻¹) [PROOFSTEP] rw [degree_mul_leadingCoeff_inv _ hq0] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp : p ≠ 0 hq : 0 < degree q hq0 : q ≠ 0 ⊢ 0 < degree q [PROOFSTEP] exact hq [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k ⊢ IsUnit (map f p) ↔ IsUnit p [PROOFSTEP] simp_rw [isUnit_iff_degree_eq_zero, degree_map] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k ⊢ map f (p / q) = map f p / map f q [PROOFSTEP] if hq0 : q = 0 then simp [hq0] else rw [div_def, div_def, Polynomial.map_mul, map_divByMonic f (monic_mul_leadingCoeff_inv hq0), Polynomial.map_mul, map_C, leadingCoeff_map, map_inv₀] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k hq0 : q = 0 ⊢ map f (p / q) = map f p / map f q [PROOFSTEP] simp [hq0] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k hq0 : ¬q = 0 ⊢ map f (p / q) = map f p / map f q [PROOFSTEP] rw [div_def, div_def, Polynomial.map_mul, map_divByMonic f (monic_mul_leadingCoeff_inv hq0), Polynomial.map_mul, map_C, leadingCoeff_map, map_inv₀] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k ⊢ map f (p % q) = map f p % map f q [PROOFSTEP] by_cases hq0 : q = 0 [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k hq0 : q = 0 ⊢ map f (p % q) = map f p % map f q [PROOFSTEP] simp [hq0] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k hq0 : ¬q = 0 ⊢ map f (p % q) = map f p % map f q [PROOFSTEP] rw [mod_def, mod_def, leadingCoeff_map f, ← map_inv₀ f, ← map_C f, ← Polynomial.map_mul f, map_modByMonic f (monic_mul_leadingCoeff_inv hq0)] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝³ : Field R p q : R[X] inst✝² : Field k inst✝¹ : DecidableEq R inst✝ : DecidableEq k f : R →+* k x : R[X] ⊢ EuclideanDomain.gcd (map f 0) (map f x) = map f (EuclideanDomain.gcd 0 x) [PROOFSTEP] simp_rw [Polynomial.map_zero, EuclideanDomain.gcd_zero_left] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝³ : Field R p q : R[X] inst✝² : Field k inst✝¹ : DecidableEq R inst✝ : DecidableEq k f : R →+* k x y : R[X] x✝ : x ≠ 0 ih : EuclideanDomain.gcd (map f (y % x)) (map f x) = map f (EuclideanDomain.gcd (y % x) x) ⊢ EuclideanDomain.gcd (map f x) (map f y) = map f (EuclideanDomain.gcd x y) [PROOFSTEP] rw [gcd_val, ← map_mod, ih, ← gcd_val] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : Field R p q : R[X] inst✝¹ : CommSemiring k inst✝ : DecidableEq R ϕ : R →+* k f g : R[X] α : k hf : eval₂ ϕ α f = 0 hg : eval₂ ϕ α g = 0 ⊢ eval₂ ϕ α (EuclideanDomain.gcd f g) = 0 [PROOFSTEP] rw [EuclideanDomain.gcd_eq_gcd_ab f g, Polynomial.eval₂_add, Polynomial.eval₂_mul, Polynomial.eval₂_mul, hf, hg, zero_mul, zero_mul, zero_add] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : Field R p q : R[X] inst✝¹ : CommSemiring k inst✝ : DecidableEq R ϕ : R →+* k f g : R[X] α : k hα : eval₂ ϕ α (EuclideanDomain.gcd f g) = 0 ⊢ eval₂ ϕ α f = 0 [PROOFSTEP] cases' EuclideanDomain.gcd_dvd_left f g with p hp [GOAL] case intro R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : Field R p✝ q : R[X] inst✝¹ : CommSemiring k inst✝ : DecidableEq R ϕ : R →+* k f g : R[X] α : k hα : eval₂ ϕ α (EuclideanDomain.gcd f g) = 0 p : R[X] hp : f = EuclideanDomain.gcd f g * p ⊢ eval₂ ϕ α f = 0 [PROOFSTEP] rw [hp, Polynomial.eval₂_mul, hα, zero_mul] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : Field R p q : R[X] inst✝¹ : CommSemiring k inst✝ : DecidableEq R ϕ : R →+* k f g : R[X] α : k hα : eval₂ ϕ α (EuclideanDomain.gcd f g) = 0 ⊢ eval₂ ϕ α g = 0 [PROOFSTEP] cases' EuclideanDomain.gcd_dvd_right f g with p hp [GOAL] case intro R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : Field R p✝ q : R[X] inst✝¹ : CommSemiring k inst✝ : DecidableEq R ϕ : R →+* k f g : R[X] α : k hα : eval₂ ϕ α (EuclideanDomain.gcd f g) = 0 p : R[X] hp : g = EuclideanDomain.gcd f g * p ⊢ eval₂ ϕ α g = 0 [PROOFSTEP] rw [hp, Polynomial.eval₂_mul, hα, zero_mul] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k ⊢ IsCoprime (map f p) (map f q) ↔ IsCoprime p q [PROOFSTEP] classical rw [← EuclideanDomain.gcd_isUnit_iff, ← EuclideanDomain.gcd_isUnit_iff, gcd_map, isUnit_map] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k ⊢ IsCoprime (map f p) (map f q) ↔ IsCoprime p q [PROOFSTEP] rw [← EuclideanDomain.gcd_isUnit_iff, ← EuclideanDomain.gcd_isUnit_iff, gcd_map, isUnit_map] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝² : Field R p q : R[X] inst✝¹ : CommRing k inst✝ : IsDomain k f : R →+* k x : k hp : p ≠ 0 ⊢ x ∈ roots (map f p) ↔ eval₂ f x p = 0 [PROOFSTEP] rw [mem_roots (map_ne_zero hp), IsRoot, Polynomial.eval_map] [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n✝ : ℕ inst✝³ : Field R p q : R[X] inst✝² : CommRing S inst✝¹ : IsDomain S inst✝ : Algebra R S n : ℕ hn : n ≠ 0 a : R ha : a ≠ 0 ⊢ rootSet (↑(monomial n) a) S = {0} [PROOFSTEP] classical rw [rootSet, map_monomial, roots_monomial ((_root_.map_ne_zero (algebraMap R S)).2 ha), Multiset.toFinset_nsmul _ _ hn, Multiset.toFinset_singleton, Finset.coe_singleton] [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n✝ : ℕ inst✝³ : Field R p q : R[X] inst✝² : CommRing S inst✝¹ : IsDomain S inst✝ : Algebra R S n : ℕ hn : n ≠ 0 a : R ha : a ≠ 0 ⊢ rootSet (↑(monomial n) a) S = {0} [PROOFSTEP] rw [rootSet, map_monomial, roots_monomial ((_root_.map_ne_zero (algebraMap R S)).2 ha), Multiset.toFinset_nsmul _ _ hn, Multiset.toFinset_singleton, Finset.coe_singleton] [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n✝ : ℕ inst✝³ : Field R p q : R[X] inst✝² : CommRing S inst✝¹ : IsDomain S inst✝ : Algebra R S n : ℕ hn : n ≠ 0 a : R ha : a ≠ 0 ⊢ rootSet (↑C a * X ^ n) S = {0} [PROOFSTEP] rw [C_mul_X_pow_eq_monomial, rootSet_monomial hn ha] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝³ : Field R p q : R[X] inst✝² : CommRing S inst✝¹ : IsDomain S inst✝ : Algebra R S n : ℕ hn : n ≠ 0 ⊢ rootSet (X ^ n) S = {0} [PROOFSTEP] rw [← one_mul (X ^ n : R[X]), ← C_1, rootSet_C_mul_X_pow hn] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝³ : Field R p q : R[X] inst✝² : CommRing S inst✝¹ : IsDomain S inst✝ : Algebra R S n : ℕ hn : n ≠ 0 ⊢ 1 ≠ 0 [PROOFSTEP] exact one_ne_zero [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝³ : Field R p q : R[X] inst✝² : CommRing S inst✝¹ : IsDomain S inst✝ : Algebra R S ι : Type u_1 f : ι → R[X] s : Finset ι h : Finset.prod s f ≠ 0 ⊢ rootSet (Finset.prod s f) S = ⋃ (i : ι) (_ : i ∈ s), rootSet (f i) S [PROOFSTEP] classical simp only [rootSet, ← Finset.mem_coe] rw [Polynomial.map_prod, roots_prod, Finset.bind_toFinset, s.val_toFinset, Finset.coe_biUnion] rwa [← Polynomial.map_prod, Ne, map_eq_zero] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝³ : Field R p q : R[X] inst✝² : CommRing S inst✝¹ : IsDomain S inst✝ : Algebra R S ι : Type u_1 f : ι → R[X] s : Finset ι h : Finset.prod s f ≠ 0 ⊢ rootSet (Finset.prod s f) S = ⋃ (i : ι) (_ : i ∈ s), rootSet (f i) S [PROOFSTEP] simp only [rootSet, ← Finset.mem_coe] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝³ : Field R p q : R[X] inst✝² : CommRing S inst✝¹ : IsDomain S inst✝ : Algebra R S ι : Type u_1 f : ι → R[X] s : Finset ι h : Finset.prod s f ≠ 0 ⊢ ↑(Multiset.toFinset (roots (map (algebraMap R S) (Finset.prod s f)))) = ⋃ (i : ι) (_ : i ∈ ↑s), ↑(Multiset.toFinset (roots (map (algebraMap R S) (f i)))) [PROOFSTEP] rw [Polynomial.map_prod, roots_prod, Finset.bind_toFinset, s.val_toFinset, Finset.coe_biUnion] [GOAL] case a R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝³ : Field R p q : R[X] inst✝² : CommRing S inst✝¹ : IsDomain S inst✝ : Algebra R S ι : Type u_1 f : ι → R[X] s : Finset ι h : Finset.prod s f ≠ 0 ⊢ ∏ i in s, map (algebraMap R S) (f i) ≠ 0 [PROOFSTEP] rwa [← Polynomial.map_prod, Ne, map_eq_zero] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 ⊢ IsRoot p (-(coeff p 0 / coeff p 1)) [PROOFSTEP] have : p.coeff 1 ≠ 0 := by have h' := natDegree_eq_of_degree_eq_some h change natDegree p = 1 at h' ; rw [← h'] exact mt leadingCoeff_eq_zero.1 fun h0 => by simp [h0] at h [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 ⊢ coeff p 1 ≠ 0 [PROOFSTEP] have h' := natDegree_eq_of_degree_eq_some h [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 h' : natDegree p = One.one ⊢ coeff p 1 ≠ 0 [PROOFSTEP] change natDegree p = 1 at h' [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 h' : natDegree p = 1 ⊢ coeff p 1 ≠ 0 [PROOFSTEP] rw [← h'] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 h' : natDegree p = 1 ⊢ coeff p (natDegree p) ≠ 0 [PROOFSTEP] exact mt leadingCoeff_eq_zero.1 fun h0 => by simp [h0] at h [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 h' : natDegree p = 1 h0 : p = 0 ⊢ False [PROOFSTEP] simp [h0] at h [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 this : coeff p 1 ≠ 0 ⊢ IsRoot p (-(coeff p 0 / coeff p 1)) [PROOFSTEP] conv in p => rw [eq_X_add_C_of_degree_le_one (show degree p ≤ 1 by rw [h])] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 this : coeff p 1 ≠ 0 | p [PROOFSTEP] rw [eq_X_add_C_of_degree_le_one (show degree p ≤ 1 by rw [h])] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 this : coeff p 1 ≠ 0 | p [PROOFSTEP] rw [eq_X_add_C_of_degree_le_one (show degree p ≤ 1 by rw [h])] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 this : coeff p 1 ≠ 0 | p [PROOFSTEP] rw [eq_X_add_C_of_degree_le_one (show degree p ≤ 1 by rw [h])] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 this : coeff p 1 ≠ 0 ⊢ degree p ≤ 1 [PROOFSTEP] rw [h] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] h : degree p = 1 this : coeff p 1 ≠ 0 ⊢ IsRoot (↑C (coeff p 1) * X + ↑C (coeff p 0)) (-(coeff p 0 / coeff p 1)) [PROOFSTEP] simp [IsRoot, mul_div_cancel' _ this] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝ : Field R p q : R[X] u : R[X]ˣ n : ℕ ⊢ (coeff (↑u) n)⁻¹ = coeff (↑u⁻¹) n [PROOFSTEP] rw [eq_C_of_degree_eq_zero (degree_coe_units u), eq_C_of_degree_eq_zero (degree_coe_units u⁻¹), coeff_C, coeff_C, inv_eq_one_div] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝ : Field R p q : R[X] u : R[X]ˣ n : ℕ ⊢ (1 / if n = 0 then coeff (↑u) 0 else 0) = if n = 0 then coeff (↑u⁻¹) 0 else 0 [PROOFSTEP] split_ifs [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝ : Field R p q : R[X] u : R[X]ˣ n : ℕ h✝ : n = 0 ⊢ 1 / coeff (↑u) 0 = coeff (↑u⁻¹) 0 [PROOFSTEP] rw [div_eq_iff_mul_eq (coeff_coe_units_zero_ne_zero u), coeff_zero_eq_eval_zero, coeff_zero_eq_eval_zero, ← eval_mul, ← Units.val_mul, inv_mul_self] [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝ : Field R p q : R[X] u : R[X]ˣ n : ℕ h✝ : n = 0 ⊢ eval 0 ↑1 = 1 [PROOFSTEP] simp [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n✝ : ℕ inst✝ : Field R p q : R[X] u : R[X]ˣ n : ℕ h✝ : ¬n = 0 ⊢ 1 / 0 = 0 [PROOFSTEP] simp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : DecidableEq R hp0 : p ≠ 0 ⊢ Monic (↑normalize p) [PROOFSTEP] rw [Ne.def, ← leadingCoeff_eq_zero, ← Ne.def, ← isUnit_iff_ne_zero] at hp0 [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : DecidableEq R hp0 : IsUnit (leadingCoeff p) ⊢ Monic (↑normalize p) [PROOFSTEP] rw [Monic, leadingCoeff_normalize, normalize_eq_one] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : DecidableEq R hp0 : IsUnit (leadingCoeff p) ⊢ IsUnit (leadingCoeff p) [PROOFSTEP] apply hp0 [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hpq : degree q ≤ degree p ⊢ leadingCoeff (p / q) = leadingCoeff p / leadingCoeff q [PROOFSTEP] by_cases hq : q = 0 [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hpq : degree q ≤ degree p hq : q = 0 ⊢ leadingCoeff (p / q) = leadingCoeff p / leadingCoeff q [PROOFSTEP] simp [hq] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hpq : degree q ≤ degree p hq : ¬q = 0 ⊢ leadingCoeff (p / q) = leadingCoeff p / leadingCoeff q [PROOFSTEP] rw [div_def, leadingCoeff_mul, leadingCoeff_C, leadingCoeff_divByMonic_of_monic (monic_mul_leadingCoeff_inv hq) _, mul_comm, div_eq_mul_inv] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hpq : degree q ≤ degree p hq : ¬q = 0 ⊢ degree (q * ↑C (leadingCoeff q)⁻¹) ≤ degree p [PROOFSTEP] rwa [degree_mul_leadingCoeff_inv q hq] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] ⊢ p / (↑C a * q) = ↑C a⁻¹ * (p / q) [PROOFSTEP] by_cases ha : a = 0 [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] ha : a = 0 ⊢ p / (↑C a * q) = ↑C a⁻¹ * (p / q) [PROOFSTEP] simp [ha] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] ha : ¬a = 0 ⊢ p / (↑C a * q) = ↑C a⁻¹ * (p / q) [PROOFSTEP] simp only [div_def, leadingCoeff_mul, mul_inv, leadingCoeff_C, C.map_mul, mul_assoc] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] ha : ¬a = 0 ⊢ ↑C a⁻¹ * (↑C (leadingCoeff q)⁻¹ * (p /ₘ (↑C a * (q * (↑C a⁻¹ * ↑C (leadingCoeff q)⁻¹))))) = ↑C a⁻¹ * (↑C (leadingCoeff q)⁻¹ * (p /ₘ (q * ↑C (leadingCoeff q)⁻¹))) [PROOFSTEP] congr 3 [GOAL] case neg.e_a.e_a.e_q R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] ha : ¬a = 0 ⊢ ↑C a * (q * (↑C a⁻¹ * ↑C (leadingCoeff q)⁻¹)) = q * ↑C (leadingCoeff q)⁻¹ [PROOFSTEP] rw [mul_left_comm q, ← mul_assoc, ← C.map_mul, mul_inv_cancel ha, C.map_one, one_mul] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] ha : a ≠ 0 x✝ : p ∣ q r : R[X] hr : q = p * r ⊢ q = ↑C a * p * (↑C a⁻¹ * r) [PROOFSTEP] rw [mul_assoc, mul_left_comm p, ← mul_assoc, ← C.map_mul, _root_.mul_inv_cancel ha, C.map_one, one_mul, hr] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] ha : a ≠ 0 x✝ : p ∣ ↑C a * q r : R[X] hr : ↑C a * q = p * r ⊢ q = p * (↑C a⁻¹ * r) [PROOFSTEP] rw [mul_left_comm p, ← hr, ← mul_assoc, ← C.map_mul, _root_.inv_mul_cancel ha, C.map_one, one_mul] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : DecidableEq R hp : p ≠ 0 ⊢ ↑(normUnit p) = ↑C (leadingCoeff p)⁻¹ [PROOFSTEP] have : p.leadingCoeff ≠ 0 := mt leadingCoeff_eq_zero.mp hp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : DecidableEq R hp : p ≠ 0 this : leadingCoeff p ≠ 0 ⊢ ↑(normUnit p) = ↑C (leadingCoeff p)⁻¹ [PROOFSTEP] simp [CommGroupWithZero.coe_normUnit _ this] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : DecidableEq R h : Monic p ⊢ ↑normalize p = p [PROOFSTEP] simp [h] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k x y : R[X] ⊢ map f x ∣ map f y ↔ x ∣ y [PROOFSTEP] by_cases H : x = 0 [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k x y : R[X] H : x = 0 ⊢ map f x ∣ map f y ↔ x ∣ y [PROOFSTEP] rw [H, Polynomial.map_zero, zero_dvd_iff, zero_dvd_iff, map_eq_zero] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k x y : R[X] H : ¬x = 0 ⊢ map f x ∣ map f y ↔ x ∣ y [PROOFSTEP] classical rw [← normalize_dvd_iff, ← @normalize_dvd_iff R[X], normalize_apply, normalize_apply, coe_normUnit_of_ne_zero H, coe_normUnit_of_ne_zero (mt (map_eq_zero f).1 H), leadingCoeff_map, ← map_inv₀ f, ← map_C, ← Polynomial.map_mul, map_dvd_map _ f.injective (monic_mul_leadingCoeff_inv H)] [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : Field k f : R →+* k x y : R[X] H : ¬x = 0 ⊢ map f x ∣ map f y ↔ x ∣ y [PROOFSTEP] rw [← normalize_dvd_iff, ← @normalize_dvd_iff R[X], normalize_apply, normalize_apply, coe_normUnit_of_ne_zero H, coe_normUnit_of_ne_zero (mt (map_eq_zero f).1 H), leadingCoeff_map, ← map_inv₀ f, ← map_C, ← Polynomial.map_mul, map_dvd_map _ f.injective (monic_mul_leadingCoeff_inv H)] [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝¹ : Field R p q : R[X] inst✝ : DecidableEq R ⊢ degree (↑normalize p) = degree p [PROOFSTEP] simp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp1 : degree p = 1 ⊢ Prime p [PROOFSTEP] classical have : Prime (normalize p) := Monic.prime_of_degree_eq_one (hp1 ▸ degree_normalize) (monic_normalize fun hp0 => absurd hp1 (hp0.symm ▸ by simp)) exact (normalize_associated _).prime this [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp1 : degree p = 1 ⊢ Prime p [PROOFSTEP] have : Prime (normalize p) := Monic.prime_of_degree_eq_one (hp1 ▸ degree_normalize) (monic_normalize fun hp0 => absurd hp1 (hp0.symm ▸ by simp)) [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp1 : degree p = 1 hp0 : p = 0 ⊢ ¬degree 0 = 1 [PROOFSTEP] simp [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] hp1 : degree p = 1 this : Prime (↑normalize p) ⊢ Prime p [PROOFSTEP] exact (normalize_associated _).prime this [GOAL] R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] x : R ⊢ ¬Irreducible (↑C x) [PROOFSTEP] by_cases H : x = 0 [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] x : R H : x = 0 ⊢ ¬Irreducible (↑C x) [PROOFSTEP] rw [H, C_0] [GOAL] case pos R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] x : R H : x = 0 ⊢ ¬Irreducible 0 [PROOFSTEP] exact not_irreducible_zero [GOAL] case neg R : Type u S : Type v k : Type y A : Type z a b : R n : ℕ inst✝ : Field R p q : R[X] x : R H : ¬x = 0 ⊢ ¬Irreducible (↑C x) [PROOFSTEP] exact fun hx => Irreducible.not_unit hx <| isUnit_C.2 <| isUnit_iff_ne_zero.2 H [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K ⊢ (X - ↑C a) * (f /ₘ (X - ↑C a)) = f - f %ₘ (X - ↑C a) [PROOFSTEP] rw [eq_sub_iff_add_eq, ← eq_sub_iff_add_eq', modByMonic_eq_sub_mul_div] [GOAL] case _hq R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K ⊢ Monic (X - ↑C a) [PROOFSTEP] exact monic_X_sub_C a [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K ⊢ f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f [PROOFSTEP] have key := by apply congrArg derivative <| X_sub_C_mul_divByMonic_eq_sub_modByMonic f a [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K ⊢ ?m.1574688 [PROOFSTEP] apply congrArg derivative <| X_sub_C_mul_divByMonic_eq_sub_modByMonic f a [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K key : ↑derivative ((X - ↑C a) * (f /ₘ (X - ↑C a))) = ↑derivative (f - f %ₘ (X - ↑C a)) ⊢ f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f [PROOFSTEP] rw [modByMonic_X_sub_C_eq_C_eval] at key [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K key : ↑derivative ((X - ↑C a) * (f /ₘ (X - ↑C a))) = ↑derivative (f - ↑C (eval a f)) ⊢ f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f [PROOFSTEP] rw [derivative_mul, derivative_sub, derivative_X, derivative_sub] at key [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K key : (1 - ↑derivative (↑C a)) * (f /ₘ (X - ↑C a)) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f - ↑derivative (↑C (eval a f)) ⊢ f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f [PROOFSTEP] rw [derivative_C, sub_zero, one_mul] at key [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K key : f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f - ↑derivative (↑C (eval a f)) ⊢ f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f [PROOFSTEP] rw [derivative_C, sub_zero] at key [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K key : f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f ⊢ f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f [PROOFSTEP] assumption /- Porting note: factored out another have statement from isCoprime_of_is_root_of_eval_derivative_ne_zero because the original proof was timing out -/ [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K hf : X - ↑C a ∣ f /ₘ (X - ↑C a) ⊢ X - ↑C a ∣ ↑derivative f [PROOFSTEP] have key := divByMonic_add_X_sub_C_mul_derivate_divByMonic_eq_derivative f a [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K hf : X - ↑C a ∣ f /ₘ (X - ↑C a) key : f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f ⊢ X - ↑C a ∣ ↑derivative f [PROOFSTEP] have ⟨u, hu⟩ := hf [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K hf : X - ↑C a ∣ f /ₘ (X - ↑C a) key : f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f u : K[X] hu : f /ₘ (X - ↑C a) = (X - ↑C a) * u ⊢ X - ↑C a ∣ ↑derivative f [PROOFSTEP] rw [← key, hu, ← mul_add (X - C a) u _] [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K hf : X - ↑C a ∣ f /ₘ (X - ↑C a) key : f /ₘ (X - ↑C a) + (X - ↑C a) * ↑derivative (f /ₘ (X - ↑C a)) = ↑derivative f u : K[X] hu : f /ₘ (X - ↑C a) = (X - ↑C a) * u ⊢ X - ↑C a ∣ (X - ↑C a) * (u + ↑derivative ((X - ↑C a) * u)) [PROOFSTEP] use(u + derivative ((X - C a) * u)) [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K hf' : eval a (↑derivative f) ≠ 0 ⊢ IsCoprime (X - ↑C a) (f /ₘ (X - ↑C a)) [PROOFSTEP] classical refine Or.resolve_left (EuclideanDomain.dvd_or_coprime (X - C a) (f /ₘ (X - C a)) (irreducible_of_degree_eq_one (Polynomial.degree_X_sub_C a))) ?_ contrapose! hf' with h have : X - C a ∣ derivative f := X_sub_C_dvd_derivative_of_X_sub_C_dvd_divByMonic f h rw [← dvd_iff_modByMonic_eq_zero (monic_X_sub_C _), modByMonic_X_sub_C_eq_C_eval] at this rwa [← C_inj, C_0] [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K hf' : eval a (↑derivative f) ≠ 0 ⊢ IsCoprime (X - ↑C a) (f /ₘ (X - ↑C a)) [PROOFSTEP] refine Or.resolve_left (EuclideanDomain.dvd_or_coprime (X - C a) (f /ₘ (X - C a)) (irreducible_of_degree_eq_one (Polynomial.degree_X_sub_C a))) ?_ [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K hf' : eval a (↑derivative f) ≠ 0 ⊢ ¬X - ↑C a ∣ f /ₘ (X - ↑C a) [PROOFSTEP] contrapose! hf' with h [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K h : X - ↑C a ∣ f /ₘ (X - ↑C a) ⊢ eval a (↑derivative f) = 0 [PROOFSTEP] have : X - C a ∣ derivative f := X_sub_C_dvd_derivative_of_X_sub_C_dvd_divByMonic f h [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K h : X - ↑C a ∣ f /ₘ (X - ↑C a) this : X - ↑C a ∣ ↑derivative f ⊢ eval a (↑derivative f) = 0 [PROOFSTEP] rw [← dvd_iff_modByMonic_eq_zero (monic_X_sub_C _), modByMonic_X_sub_C_eq_C_eval] at this [GOAL] R : Type u S : Type v k : Type y A : Type z a✝ b : R n : ℕ inst✝¹ : Field R p q : R[X] K : Type u_1 inst✝ : Field K f : K[X] a : K h : X - ↑C a ∣ f /ₘ (X - ↑C a) this : ↑C (eval a (↑derivative f)) = 0 ⊢ eval a (↑derivative f) = 0 [PROOFSTEP] rwa [← C_inj, C_0]
State Before: α : Type u_1 β : Type ?u.124878 s✝ t✝ : Set α a b x y : α f : α → β s t : Set α ht : autoParam (Set.Finite t) _auto✝ ⊢ ncard s ≤ ncard (s \ t) + ncard t State After: case inl α : Type u_1 β : Type ?u.124878 s✝ t✝ : Set α a b x y : α f : α → β s t : Set α ht : autoParam (Set.Finite t) _auto✝ h : Set.Finite s ⊢ ncard s ≤ ncard (s \ t) + ncard t case inr α : Type u_1 β : Type ?u.124878 s✝ t✝ : Set α a b x y : α f : α → β s t : Set α ht : autoParam (Set.Finite t) _auto✝ h : Set.Infinite s ⊢ ncard s ≤ ncard (s \ t) + ncard t Tactic: cases' s.finite_or_infinite with h h State Before: case inr α : Type u_1 β : Type ?u.124878 s✝ t✝ : Set α a b x y : α f : α → β s t : Set α ht : autoParam (Set.Finite t) _auto✝ h : Set.Infinite s ⊢ ncard s ≤ ncard (s \ t) + ncard t State After: case h.e'_3 α : Type u_1 β : Type ?u.124878 s✝ t✝ : Set α a b x y : α f : α → β s t : Set α ht : autoParam (Set.Finite t) _auto✝ h : Set.Infinite s ⊢ ncard s = 0 Tactic: convert Nat.zero_le _ State Before: case h.e'_3 α : Type u_1 β : Type ?u.124878 s✝ t✝ : Set α a b x y : α f : α → β s t : Set α ht : autoParam (Set.Finite t) _auto✝ h : Set.Infinite s ⊢ ncard s = 0 State After: no goals Tactic: rw [h.ncard] State Before: case inl α : Type u_1 β : Type ?u.124878 s✝ t✝ : Set α a b x y : α f : α → β s t : Set α ht : autoParam (Set.Finite t) _auto✝ h : Set.Finite s ⊢ ncard s ≤ ncard (s \ t) + ncard t State After: case inl α : Type u_1 β : Type ?u.124878 s✝ t✝ : Set α a b x y : α f : α → β s t : Set α ht : autoParam (Set.Finite t) _auto✝ h : Set.Finite s ⊢ ncard (t ∩ s) ≤ ncard t Tactic: rw [← diff_inter_self_eq_diff, ← ncard_diff_add_ncard_eq_ncard (inter_subset_right t s) h, add_le_add_iff_left] State Before: case inl α : Type u_1 β : Type ?u.124878 s✝ t✝ : Set α a b x y : α f : α → β s t : Set α ht : autoParam (Set.Finite t) _auto✝ h : Set.Finite s ⊢ ncard (t ∩ s) ≤ ncard t State After: no goals Tactic: apply ncard_inter_le_ncard_left _ _ ht
[STATEMENT] lemma dg_Par_Obj_iff: "x \<in>\<^sub>\<circ> dg_Par \<alpha>\<lparr>Obj\<rparr> \<longleftrightarrow> x \<in>\<^sub>\<circ> Vset \<alpha>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. (x \<in>\<^sub>\<circ> dg_Par \<alpha>\<lparr>Obj\<rparr>) = (x \<in>\<^sub>\<circ> Vset \<alpha>) [PROOF STEP] unfolding dg_Par_components [PROOF STATE] proof (prove) goal (1 subgoal): 1. (x \<in>\<^sub>\<circ> Vset \<alpha>) = (x \<in>\<^sub>\<circ> Vset \<alpha>) [PROOF STEP] by auto
#Objetivo: dibujar la "curva ROC de una variable" #limpio la memoria rm(list=ls()) gc() library("data.table") setwd("E:/UBA/2019-II/DM en Finanzas/Dropbox Prof/datasets") #cargo los datos dataset <- fread("201902.txt") #creo una clase que se 1 cuando es BAJA+2 , y 0 en caso contrario #esto me simplifica las cuentas dataset[ , clase01:= as.numeric(clase_ternaria=="BAJA+2") ] #creo una variable azar que me va a ser util #para ordenar al azar los registros que tienen el mismo valor para un campo #asi el dibujo de la curva ROC de ese segmento es una recta dataset[ , azar := runif(nrow(dataset)) ] #calculos basicos universo <- nrow(dataset ) pos_total <- sum(dataset$clase01 ) neg_total <- universo - pos_total #Creo dos funciones de forma de poder superponer varios cortes de una misma variable #------------------------------------------------------------- graficar_init = function() { #calculos basicos universo <- nrow(dataset ) pos_total <- sum(dataset$clase01 ) neg_total <- universo - pos_total #la diagonal azar_neg <- c( 0, neg_total ) azar_pos <- c( 0, pos_total ) #grafico plot( azar_neg, azar_pos, type="n", main=paste( "ROC Curve" ), xlab="neg", ylab="pos", pch=19) lines( azar_neg, azar_pos, type="l" , col="black", lwd=2) } #---------------------- pred_graficar = function(dataset, pcolumna, pvalor ) { #calculos basicos universo <- nrow(dataset ) pos_total <- sum(dataset$clase01 ) neg_total <- universo - pos_total pos_pred <- sum( dataset[ get(pcolumna) <= pvalor , clase01] ) neg_pred <- sum( 1 - dataset[ get(pcolumna) <= pvalor, clase01] ) AUC <- (pos_pred*neg_pred + (pos_pred + pos_total)*(neg_total-neg_pred) ) / (2*pos_total*neg_total) #creo el vector con los tres puntos vneg <- c( 0, neg_pred, neg_total ) vpos <- c( 0, pos_pred, pos_total ) #grafico lines( vneg, vpos, type="l" , col="green", lwd=2) return( AUC ) } #---------------------- graficar_init() #ejecutar las instrucciones de a una y ver el efecto pred_graficar( dataset, "mcuentas_saldo", -100000 ) pred_graficar( dataset, "mcuentas_saldo", -10000 ) pred_graficar( dataset, "mcuentas_saldo", -2000 ) pred_graficar( dataset, "mcuentas_saldo", 0 ) pred_graficar( dataset, "mcuentas_saldo", 10000 )#Mejor AUC pred_graficar( dataset, "mcuentas_saldo", 50000 ) pred_graficar( dataset, "mcuentas_saldo", 100000 ) #---------------------- #Concepto fundamental #se ordena el dataset por una variable #y se lleva el conteo de positivos y negativos columna_graficar = function(dataset, pcolumna ) { #calculos basicos universo <- nrow(dataset ) pos_total <- sum(dataset$clase01 ) neg_total <- universo - pos_total #ordeno por <pcolumna, azar> #dentro de los registros que tienen el mismo valor de pcolumna, ordeno por el campo que invente llamado azar #los NA de pcolumna van al inicio del orden univar <- dataset[ order(get(pcolumna), na.last=FALSE, azar), c("clase01", pcolumna), with=FALSE] #acumulo positivos y negativos, operacion vectorial neg_acum <- cumsum( 1- univar$clase01 ) pos_acum <- cumsum( univar$clase01 ) #dibujo la curva, que esta compuesta de miles de puntos lines( neg_acum, pos_acum, type="l" , col="red", lwd=2) #calculo el vector de cada AUC, que consiste en cortar exactamente en ese punto AUC_vector <- ( pos_acum*neg_acum + (pos_acum+pos_total)*(neg_total-neg_acum) ) / (2*pos_total*neg_total) #voy a calcular cual es el corte que genera la mayor AUC return( list( "variable"= pcolumna, "valor" = univar[ which.max( AUC_vector ), get(pcolumna)], "AUC_max" = max( AUC_vector) ) ) } #---------------------- columna_graficar( dataset, "mcuentas_saldo" )#AUC_mAX de 0.75 columna_graficar( dataset, "cliente_edad" ) columna_graficar( dataset, "Visa_mconsumototal" )#AUC_mAX de 0.732 columna_graficar( dataset, "ttarjeta_visa" ) columna_graficar( dataset, "ttarjeta_master" ) columna_graficar( dataset, "Visa_cuenta_estado" ) #ahora uso el valor optimo que encontre en la instruccion anterior #cortar mcuentas_saldo en 1275.59 graficar_init() pred_graficar( dataset, "mcuentas_saldo", 1275.59 ) columna_graficar( dataset, "mcuentas_saldo" )#AUC_mAX de 0.75 #cortar Visa_mconsumototal en 863.19 graficar_init() pred_graficar( dataset, "Visa_mconsumototal", 863.19 ) columna_graficar( dataset, "Visa_mconsumototal" )#AUC_mAX de 0.732 #cortar cliente_edad en 36 graficar_init() pred_graficar( dataset, "cliente_edad", 36 ) columna_graficar( dataset, "cliente_edad" )#AUC_mAX de 0.527 #como da la tabla de contingencia de mcuentas_saldo ftable(dataset[ mcuentas_saldo <= 1275.59, clase_ternaria]) ftable(dataset[ mcuentas_saldo > 1275.59, clase_ternaria]) #como da la tabla de contingencia de Visa_mconsumototal ftable(dataset[ Visa_mconsumototal <= 863.19, clase_ternaria]) ftable(dataset[ Visa_mconsumototal > 863.19, clase_ternaria]) #----------------------- #Desvio, calcular la ganancia acumulada columna_graficar_ganancia = function(dataset, pcolumna ) { #calculos basicos universo <- nrow(dataset ) pos_total <- sum(dataset$clase01 ) neg_total <- universo - pos_total #ordeno por <pcolumna, azar> #dentro de los registros que tienen el mismo valor de pcolumna, ordeno por el campo que invente llamado azar #los NA de pcolumna van al inicio del orden univar <- dataset[ order(get(pcolumna), na.last=FALSE, azar), c("clase01", pcolumna), with=FALSE] #acumulo positivos y negativos, operacion vectorial neg_acum <- cumsum( 1- univar$clase01 ) pos_acum <- cumsum( univar$clase01 ) gan_acum <- 19500*pos_acum - 500*neg_acum #grafico plot( seq(universo), gan_acum, type="n", main=paste( "Ganancia ordenado por", pcolumna ), xlab="registros", ylab="Ganancia", pch=19) lines( seq(universo), gan_acum, type="l" , col="blue", lwd=2) return( list( "variable"= pcolumna, "valor" = univar[ which.max( gan_acum ), get(pcolumna)], "gan_max" = max( gan_acum), "regis" = which.max( gan_acum ) ) ) } #--------------------- columna_graficar_ganancia( dataset, "mcuentas_saldo" )#AUC_mAX de 0.75 columna_graficar_ganancia( dataset, "cliente_edad" ) columna_graficar_ganancia( dataset, "Visa_mconsumototal" )#AUC_mAX de 0.732 columna_graficar_ganancia( dataset, "ttarjeta_visa" ) columna_graficar_ganancia( dataset, "ttarjeta_master" ) columna_graficar_ganancia( dataset, "Visa_cuenta_estado" ) # Y ahora graficando los primeros n registros columna_graficar_ganancia_n = function(dataset, pcolumna, pcantidad ) { #calculos basicos universo <- nrow(dataset ) pos_total <- sum(dataset$clase01 ) neg_total <- universo - pos_total #ordeno por <pcolumna, azar> univar <- dataset[ order(get(pcolumna), na.last=FALSE, azar), c("clase01", pcolumna), with=FALSE] #acumulo positivos y negativos, operacion vectorial neg_acum <- cumsum( 1- univar$clase01 ) pos_acum <- cumsum( univar$clase01 ) gan_acum <- 19500*pos_acum - 500*neg_acum #grafico plot( seq(pcantidad), gan_acum[1:pcantidad], type="n", main=paste( "Ganancia ordenado por", pcolumna ), xlab="registros", ylab="Ganancia", pch=19) lines( seq(pcantidad), gan_acum[1:pcantidad], type="l" , col="blue", lwd=2) return( list( "variable"= pcolumna, "valor" = univar[ which.max( gan_acum ), get(pcolumna)], "gan_max" = max( gan_acum), "regis" = which.max( gan_acum ) ) ) } #--------------------- columna_graficar_ganancia_n( dataset, "mcuentas_saldo", 20000 ) columna_graficar_ganancia_n( dataset, "Visa_mconsumototal", 40000 )
from random import Random import cv2 import numpy as np import torch.utils.data as data import torchvision.transforms as transforms import os from PIL import Image from util import imread16 class FilmDustDataset(data.Dataset): def __init__(self, rootdir): self.rootdir = rootdir listdir = os.listdir(rootdir) alphapaths = list(filter(lambda n: n.endswith("_alpha.png"), listdir)) paths = list(filter(lambda n: n.endswith(".png") and not n.endswith("_alpha.png"), listdir)) da = {i.replace("_alpha.png", ""): i for i in alphapaths} dp = {i.replace(".png", ""): i for i in paths} self.okpaths = list(map(lambda k: dp[k], (filter(lambda k: k in dp, da.keys())))) self.rnd = Random(42434445) self.totensor = transforms.ToTensor() self.dilation_kernel = np.ones((3, 3), np.uint8) def __getitem__(self, index): idx = index path = self.okpaths[idx] apath = path.replace(".png", "_alpha.png") # print(path, ":", apath) cimg = imread16(os.path.join(self.rootdir, path)) cmask = Image.open(os.path.join(self.rootdir, apath)) timg = self.totensor(cimg) dust = self.totensor(cmask) cmasknp = np.array(cmask, dtype=np.float32) dilated = cv2.dilate(cmasknp, self.dilation_kernel, iterations=1) / 255.0 cmasksum = (cmasknp / 255.0).sum() assert cmasksum > 0, "no pixels in mask " + apath dilatedsum = dilated.sum() while dilatedsum / cmasksum < 2: dilated = cv2.dilate(dilated, self.dilation_kernel, iterations=1) dilatedsum = dilated.sum() if dilatedsum == cmasksum: # dilation impossible break dt = self.totensor(dilated) return {'img': timg, 'mask': dust, 'dilated': dt, 'dilated_pixcnt': dt.sum(), 'path': path} def __len__(self): return len(self.okpaths)
In 1839 the City of Galveston adopted a charter and was incorporated by the Congress of the Republic of Texas . The city was by then a burgeoning port of entry and attracted many new residents in the 1840s and later among the flood of German immigrants to Texas , including Jewish merchants . Together with ethnic Mexican residents , these groups tended to oppose slavery , support the Union during the Civil War , and join the Republican Party after the war .
{-# OPTIONS --cubical --safe #-} module Cubical.Data.Sigma.Base where open import Cubical.Core.Primitives public -- Σ-types are defined in Core/Primitives as they are needed for Glue types.
theory Predicate_Formulas imports "HOL-Library.Countable" "HOL-Library.Infinite_Set" "HOL-Eisbach.Eisbach" Abstract_Formula begin text \<open>This theory contains an example instantiation of @{term Abstract_Formulas} with an formula type with local constants. It is a rather ad-hoc type that may not be very useful to work with, though.\<close> type_synonym var = nat type_synonym lconst = nat text \<open> We support higher order variables, in order to express \<open>\<forall>x.?P x\<close>. But we stay first order, i.e. the parameters of such a variables will only be instantiated with ground terms. \<close> datatype form = Var (var:var) (params: "form list") | LC (var:lconst) | Op (name:string) (params: "form list") | Quant (name:string) (var:nat) (body: form) type_synonym schema = "var list \<times> form" type_synonym subst = "(nat \<times> schema) list" fun fv :: "form \<Rightarrow> var set" where "fv (Var v xs) = insert v (Union (fv ` set xs))" | "fv (LC v) = {}" | "fv (Op n xs) = Union (fv ` set xs)" | "fv (Quant n v f) = fv f - {v}" definition fresh_for :: "var set \<Rightarrow> var" where "fresh_for V = (SOME n. n \<notin> V)" lemma fresh_for_fresh: "finite V \<Longrightarrow> fresh_for V \<notin> V" unfolding fresh_for_def apply (rule someI2_ex) using infinite_nat_iff_unbounded_le apply auto done text \<open>Free variables\<close> fun fv_schema :: "schema \<Rightarrow> var set" where "fv_schema (ps,f) = fv f - set ps" definition fv_subst :: "subst \<Rightarrow> var set" where "fv_subst s = \<Union>(fv_schema ` ran (map_of s))" definition fv_subst1 where "fv_subst1 s = \<Union>(fv ` snd ` set s)" lemma fv_subst_Nil[simp]: "fv_subst1 [] = {}" unfolding fv_subst1_def by auto text \<open>Local constants, separate from free variables.\<close> fun lc :: "form \<Rightarrow> lconst set" where "lc (Var v xs) = Union (lc ` set xs)" | "lc (LC c) = {c}" | "lc (Op n xs) = Union (lc ` set xs)" | "lc (Quant n v f) = lc f" fun lc_schema :: "schema \<Rightarrow> lconst set" where "lc_schema (ps,f) = lc f" definition lc_subst1 where "lc_subst1 s = \<Union>(lc ` snd ` set s)" fun lc_subst :: "subst \<Rightarrow> lconst set" where "lc_subst s = \<Union>(lc_schema ` snd ` set s)" fun map_lc :: "(lconst \<Rightarrow> lconst) \<Rightarrow> form \<Rightarrow> form" where "map_lc f (Var v xs) = Var v (map (map_lc f) xs)" | "map_lc f (LC n) = LC (f n)" | "map_lc f (Op n xs) = Op n (map (map_lc f) xs)" | "map_lc f (Quant n v f') = Quant n v (map_lc f f')" lemma fv_map_lc[simp]: "fv (map_lc p f) = fv f" by (induction f) auto lemma lc_map_lc[simp]: "lc (map_lc p f) = p ` lc f" by (induction f) auto lemma map_lc_map_lc[simp]: "map_lc p1 (map_lc p2 f) = map_lc (p1 \<circ> p2) f" by (induction f) auto fun map_lc_subst1 :: "(lconst \<Rightarrow> lconst) \<Rightarrow> (var \<times> form) list \<Rightarrow> (var \<times> form) list" where "map_lc_subst1 f s = map (apsnd (map_lc f)) s" fun map_lc_subst :: "(lconst \<Rightarrow> lconst) \<Rightarrow> subst \<Rightarrow> subst" where "map_lc_subst f s = map (apsnd (apsnd (map_lc f))) s" lemma map_lc_noop[simp]: "lc f = {} \<Longrightarrow> map_lc p f = f" by (induction f) (auto simp add: map_idI) lemma map_lc_cong[cong]: "(\<And>x. x \<in> lc f \<Longrightarrow> f1 x = f2 x) \<Longrightarrow> map_lc f1 f = map_lc f2 f" by (induction f) auto lemma map_lc_subst_cong[cong]: assumes "(\<And>x. x \<in> lc_subst s \<Longrightarrow> f1 x = f2 x)" shows "map_lc_subst f1 s = map_lc_subst f2 s" by (force intro!: map_lc_cong assms) text \<open>In order to make the termination checker happy, we define substitution in two stages: One that substitutes only ground terms for variables, and the real one that can substitute schematic terms (or lambda expression, if you want).\<close> fun subst1 :: "(var \<times> form) list \<Rightarrow> form \<Rightarrow> form" where "subst1 s (Var v []) = (case map_of s v of Some f \<Rightarrow> f | None \<Rightarrow> Var v [])" | "subst1 s (Var v xs) = Var v xs" | "subst1 s (LC n) = LC n" | "subst1 s (Op n xs) = Op n (map (subst1 s) xs)" | "subst1 s (Quant n v f) = (if v \<in> fv_subst1 s then (let v' = fresh_for (fv_subst1 s) in Quant n v' (subst1 ((v, Var v' [])#s) f)) else Quant n v (subst1 s f))" lemma apsnd_def': "apsnd f = (\<lambda>(k, v). (k, f v))" by auto lemma map_of_map_apsnd: "map_of (map (apsnd f) xs) = map_option f \<circ> map_of xs" unfolding apsnd_def' by (rule map_of_map) lemma map_lc_subst1[simp]: "map_lc p (subst1 s f) = subst1 (map_lc_subst1 p s) (map_lc p f)" apply (induction s f rule: subst1.induct) apply (auto split: option.splits simp add: map_of_map_apsnd Let_def) apply (subst subst1.simps, auto split: option.splits)[1] apply (subst subst1.simps, auto split: option.splits)[1] apply (subst subst1.simps, auto split: option.splits)[1] apply (subst subst1.simps, auto split: option.splits)[1] apply (subst subst1.simps, auto split: option.splits, simp only: Let_def map_lc.simps)[1] apply (subst subst1.simps, auto split: option.splits) done fun subst' :: "subst \<Rightarrow> form \<Rightarrow> form" where "subst' s (Var v xs) = (case map_of s v of None \<Rightarrow> (Var v (map (subst' s) xs)) | Some (ps,rhs) \<Rightarrow> if length ps = length xs then subst1 (zip ps (map (subst' s) xs)) rhs else (Var v (map (subst' s) xs)))" | "subst' s (LC n) = LC n" | "subst' s (Op n xs) = Op n (map (subst' s) xs)" | "subst' s (Quant n v f) = (if v \<in> fv_subst s then (let v' = fresh_for (fv_subst s) in Quant n v' (subst' ((v,([], Var v' []))#s) f)) else Quant n v (subst' s f))" lemma subst'_Nil[simp]: "subst' [] f = f" by (induction f) (auto simp add: map_idI fv_subst_def) lemma lc_subst': "lc (subst' s f) \<subseteq> lc f \<union> lc_subst s" apply (induction s f rule: subst'.induct) apply (auto split: option.splits dest: map_of_SomeD dest!: subsetD[OF lc_subst1] simp add: fv_subst_def) apply (fastforce dest!: set_zip_rightD)+ done lemma ran_map_option_comp[simp]: "ran (map_option f \<circ> m) = f ` ran m" unfolding comp_def by (rule ran_map_option) lemma fv_schema_apsnd_map_lc[simp]: "fv_schema (apsnd (map_lc p) a) = fv_schema a" by (cases a) auto lemma fv_subst_map_apsnd_map_lc[simp]: "fv_subst (map (apsnd (apsnd (map_lc p))) s) = fv_subst s" unfolding fv_subst_def by (auto simp add: map_of_map_apsnd) lemma map_apsnd_zip[simp]: "map (apsnd f) (zip a b) = zip a (map f b)" by (simp add: apsnd_def' zip_map2) lemma map_lc_subst'[simp]: "map_lc p (subst' s f) = subst' (map_lc_subst p s) (map_lc p f)" apply (induction s f rule: subst'.induct) apply (auto split: option.splits dest: map_of_SomeD simp add: map_of_map_apsnd Let_def) apply (solves \<open>(subst subst'.simps, auto split: option.splits)[1]\<close>) apply (solves \<open>(subst subst'.simps, auto split: option.splits cong: map_cong)[1]\<close>) apply (solves \<open>(subst subst'.simps, auto split: option.splits)[1]\<close>) apply (solves \<open>(subst subst'.simps, auto split: option.splits)[1]\<close>) apply (solves \<open>(subst subst'.simps, auto split: option.splits)[1]\<close>) apply (solves \<open>(subst subst'.simps, auto split: option.splits, simp only: Let_def map_lc.simps)[1]\<close>) apply (solves \<open>(subst subst'.simps, auto split: option.splits)[1]\<close>) done text \<open>Since subst' happily renames quantified variables, we have a simple wrapper that ensures that the substitution is minimal, and is empty if \<open>f\<close> is closed. This is a hack to support lemma \<open>subst_noop\<close>. \<close> fun subst :: "subst \<Rightarrow> form \<Rightarrow> form" where "subst s f = subst' (filter (\<lambda> (v,s). v \<in> fv f) s) f" lemma subst_Nil[simp]: "subst [] f = f" by auto lemma subst_noop[simp]: "fv f = {} \<Longrightarrow> subst s f = f" by simp lemma lc_subst: "lc (subst s f) \<subseteq> lc f \<union> lc_subst s" by (auto dest: subsetD[OF lc_subst']) lemma lc_subst_map_lc_subst[simp]: "lc_subst (map_lc_subst p s) = p ` lc_subst s" by force lemma map_lc_subst[simp]: "map_lc p (subst s f) = subst (map_lc_subst p s) (map_lc p f)" unfolding subst.simps by (auto simp add: filter_map intro!: arg_cong[OF filter_cong] ) fun closed :: "form \<Rightarrow> bool" where "closed f \<longleftrightarrow> fv f = {} \<and> lc f = {}" interpretation predicate: Abstract_Formulas "curry to_nat :: nat \<Rightarrow> var \<Rightarrow> var" map_lc lc "closed" subst lc_subst map_lc_subst "Var 0 []" apply unfold_locales apply (solves fastforce) apply (solves fastforce) apply (solves fastforce) apply (solves fastforce) apply (solves fastforce) apply (solves \<open>rule lc_subst\<close>) apply (solves fastforce) apply (solves fastforce) apply (solves fastforce) apply (solves \<open>metis map_lc_subst_cong\<close>) apply (solves \<open>rule lc_subst_map_lc_subst\<close>) apply (solves simp) apply (solves \<open>rule exI[where x = "[]"], simp\<close>) apply (solves \<open>rename_tac f, rule_tac x = "[(0, ([],f))]" in exI, simp\<close>) done declare predicate.subst_lconsts_empty_subst [simp del] end
module Control.App import Data.IORef public export Error : Type Error = Type public export Environment : Type Environment = List Error public export data HasErr : Error -> List Error -> Type where Here : HasErr e (e :: es) There : HasErr e es -> HasErr e (e' :: es) public export data Path : Type where [noHints] MayThrow : Path NoThrow : Path %hint public export dpath : Path dpath = MayThrow public export data Usage : Type where [noHints] One : Usage Any : Usage %hint public export dusage : Usage dusage = One public export 0 Has : List (a -> Type) -> a -> Type Has [] es = () Has [e] es = e es Has (e :: es') es = (e es, Has es' es) public export 0 excTy : List Error -> List Type excTy [] = [] excTy (e :: es) = e :: excTy es data OneOf : List Type -> Path -> Type where First : e -> OneOf (e :: es) MayThrow Later : OneOf es MayThrow -> OneOf (e :: es) MayThrow public export data SafeBind : Path -> (l' : Path) -> Type where [search l'] SafeSame : SafeBind l l SafeToThrow : SafeBind NoThrow MayThrow updateP : SafeBind p p' => OneOf es p -> OneOf es p' updateP @{SafeSame} x = x updateP @{SafeToThrow} x impossible Uninhabited (OneOf [] p) where uninhabited (First x) impossible uninhabited (Later x) impossible Uninhabited (OneOf es NoThrow) where uninhabited (First x) impossible uninhabited (Later x) impossible 0 execTy : Path -> List Error -> Type -> Type execTy p es ty = Either (OneOf (excTy es) p) ty data AppRes : Type -> Type where MkAppRes : (result : a) -> (1 x : %World) -> AppRes a data App1Res : Usage -> Type -> Type where MkApp1Res1 : (1 result : a) -> (1 x : %World) -> App1Res One a MkApp1ResW : (result : a) -> (1 x : %World) -> App1Res Any a PrimApp : Type -> Type PrimApp a = (1 x : %World) -> AppRes a prim_app_pure : a -> PrimApp a prim_app_pure x = \w => MkAppRes x w prim_app_bind : (1 act : PrimApp a) -> (1 k : a -> PrimApp b) -> PrimApp b prim_app_bind fn k w = let MkAppRes x' w' = fn w in k x' w' toPrimApp : IO a -> PrimApp a toPrimApp x = \w => case toPrim x w of MkIORes r w => MkAppRes r w PrimApp1 : Usage -> Type -> Type PrimApp1 u a = (1 x : %World) -> App1Res u a toPrimApp1 : {u : _} -> IO a -> PrimApp1 u a toPrimApp1 x = \w => case toPrim x w of MkIORes r w => case u of One => MkApp1Res1 r w Any => MkApp1ResW r w export data App : (l : Path) => (e : Environment) -> Type -> Type where MkApp : (1 prog : (1 w : %World) -> AppRes (execTy l e t)) -> App {l} e t export data App1 : (u : Usage) => (e : Environment) -> Type -> Type where MkApp1 : (1 prog : (1 w : %World) -> App1Res u t) -> App1 {u} e t bindApp : SafeBind l l' => App {l} e a -> (a -> App {l=l'} e b) -> App {l=l'} e b bindApp (MkApp prog) next = MkApp $ \world => let MkAppRes x' world' = prog world in case x' of Right res => let MkApp r = next res in r world' Left err => MkAppRes (Left (updateP err)) world' public export Cont1Type : Usage -> Type -> Usage -> List Error -> Type -> Type Cont1Type One a u e b = (1 x : a) -> App1 {u} e b Cont1Type Any a u e b = (x : a) -> App1 {u} e b export bindApp1 : {u : _} -> (1 act : App1 {u} e a) -> (1 k : Cont1Type u a u' e b) -> App1 {u=u'} e b bindApp1 {u=One} (MkApp1 fn) = \k => MkApp1 (\w => let MkApp1Res1 x' w' = fn w MkApp1 res = k x' in res w') bindApp1 {u=Any} (MkApp1 fn) = \k => MkApp1 (\w => let MkApp1ResW x' w' = fn w MkApp1 res = k x' in res w') absurdWith1 : (1 w : b) -> OneOf e NoThrow -> any absurdWith1 w (First p) impossible absurdWith2 : (1 x : a) -> (1 w : b) -> OneOf e NoThrow -> any absurdWith2 x w (First p) impossible export bindL : App {l=NoThrow} e a -> (1 k : a -> App {l} e b) -> App {l} e b bindL (MkApp prog) next = MkApp $ \world => let MkAppRes x' world' = prog world in case x' of Right res => let MkApp r = next res in r world' Left err => absurdWith2 next world' err export app : (1 p : App {l=NoThrow} e a) -> App1 {u=Any} e a app (MkApp prog) = MkApp1 $ \world => let MkAppRes x' world' = prog world in case x' of Left err => absurdWith1 world' err Right res => MkApp1ResW res world' export app1 : (1 p : App1 {u=Any} e a) -> App {l} e a app1 (MkApp1 prog) = MkApp $ \world => let MkApp1ResW x' world' = prog world in MkAppRes (Right x') world' pureApp : a -> App {l} e a pureApp x = MkApp $ \w => MkAppRes (Right x) w export Functor (App {l} es) where map f ap = bindApp ap $ \ap' => pureApp (f ap') export Applicative (App {l} es) where pure = pureApp (<*>) f a = bindApp f $ \f' => bindApp a $ \a' => pure (f' a') export Monad (App es) where (>>=) = bindApp -- won't get used, but handy to have the instance export (>>=) : SafeBind l l' => App {l} e a -> (k : a -> App {l=l'} e b) -> App {l=l'} e b (>>=) = bindApp namespace App1 export (>>=) : {u : _} -> (1 act : App1 {u} e a) -> (1 k : Cont1Type u a u' e b) -> App1 {u=u'} e b (>>=) = bindApp1 export pure : (x : a) -> App1 {u=Any} e a pure x = MkApp1 $ \w => MkApp1ResW x w export pure1 : (1 x : a) -> App1 e a pure1 x = MkApp1 $ \w => MkApp1Res1 x w export data State : (tag : a) -> Type -> List Error -> Type where [search tag] MkState : IORef t -> State tag t e %hint export mapState : State tag t e -> State tag t (eff :: e) mapState (MkState s) = MkState s export get : (0 tag : _) -> State tag t e => App {l} e t get tag @{MkState r} = MkApp $ prim_app_bind (toPrimApp $ readIORef r) $ \val => MkAppRes (Right val) export put : (0 tag : _) -> State tag t e => t -> App {l} e () put tag @{MkState r} val = MkApp $ prim_app_bind (toPrimApp $ writeIORef r val) $ \val => MkAppRes (Right ()) export modify : (0 tag : _) -> State tag t e => (t -> t) -> App {l} e () modify tag f = do x <- get tag put tag (f x) export new : t -> (State tag t e => App {l} e a) -> App {l} e a new val prog = MkApp $ prim_app_bind (toPrimApp $ newIORef val) $ \ref => let st = MkState ref MkApp res = prog @{st} in res public export interface Exception err e where throw : err -> App e a catch : App e a -> (err -> App e a) -> App e a findException : HasErr e es -> e -> OneOf (excTy es) MayThrow findException Here err = First err findException (There p) err = Later $ findException p err findError : HasErr e es -> OneOf (excTy es) MayThrow -> Maybe e findError Here (First err) = Just err findError (There p) (Later q) = findError p q findError _ _ = Nothing export HasErr e es => Exception e es where throw err = MkApp $ MkAppRes (Left (findException %search err)) catch (MkApp prog) handler = MkApp $ prim_app_bind prog $ \res => case res of Left err => case findError %search err of Nothing => MkAppRes (Left err) Just err' => let MkApp e' = handler err' in e' Right ok => MkAppRes (Right ok) export handle : App (err :: e) a -> (onok : a -> App e b) -> (onerr : err -> App e b) -> App e b handle (MkApp prog) onok onerr = MkApp $ prim_app_bind prog $ \res => case res of Left (First err) => let MkApp err' = onerr err in err' Left (Later p) => -- different exception, so rethrow MkAppRes (Left p) Right ok => let MkApp ok' = onok ok in ok' export lift : App e a -> App (err :: e) a lift (MkApp prog) = MkApp $ prim_app_bind prog $ \res => case res of Left err => MkAppRes (Left (Later err)) Right ok => MkAppRes (Right ok) public export Init : List Error Init = [Void] export run : App {l} Init a -> IO a run (MkApp prog) = primIO $ \w => case (prim_app_bind prog $ \r => case r of Right res => MkAppRes res Left (First err) => absurd err) w of MkAppRes r w => MkIORes r w public export interface PrimIO e where primIO : IO a -> App {l} e a -- fork starts a new environment, so that any existing state can't get -- passed to it (since it'll be tagged with the wrong environment) fork : (forall e' . PrimIO e' => App {l} e' ()) -> App e () export HasErr Void e => PrimIO e where primIO op = MkApp $ \w => let MkAppRes r w = toPrimApp op w in MkAppRes (Right r) w fork thread = MkApp $ prim_app_bind (toPrimApp $ Prelude.fork $ do run thread pure ()) $ \_ => MkAppRes (Right ()) public export data FileEx = GenericFileEx Int -- errno | FileReadError | FileWriteError | FileNotFound | PermissionDenied | FileExists export Show FileEx where show (GenericFileEx errno) = "File error: " ++ show errno show FileReadError = "File Read Error" show FileWriteError = "File Write Error" show FileNotFound = "File Not Found" show PermissionDenied = "Permission Denied" show FileExists = "File Exists" public export data IOError = GenericErr String | FileErr FileEx export Show IOError where show (GenericErr str) = "IO error: " ++ str show (FileErr f) = "File error: " ++ show f
import sys import time import numpy as np import os from pyspark import SparkContext if __name__ == "__main__": sc = SparkContext(appName="LR") D = 10 # Number of dimensions iterations = 20 N = 10 if len(sys.argv)>1: N = int(sys.argv[1]) if len(sys.argv)>2: iterations = int(sys.argv[2]) if len(sys.argv)>3: D = int(sys.argv[3]) print("N %d D %d iterations %d" %(N,D,iterations)) points = sc.parallelize(range(1,N)).mapPartitions(lambda r: [np.random.ranf(size=(len(list(r)),D+1))]) points.cache().first() start = time.time() w = 2 * np.random.ranf(size=D) - 1 print("Initial w: " + str(w)) # Compute logistic regression gradient for a matrix of data points def gradient(matrix, w): Y = matrix[:, 0] # point labels (first column of input file) X = matrix[:, 1:] # point coordinates # For each point (x, y), compute gradient function, then sum these up return ((1.0 / (1.0 + np.exp(-Y * X.dot(w))) - 1.0) * Y * X.T).sum(1) def add(x, y): x += y return x for i in range(iterations): #print("On iteration %i" % (i + 1)) w -= points.map(lambda m: gradient(m, w)).reduce(add) print("Final w: " + str(w)) print("lr exec time %f" % (time.time()-start)) sc.stop()
function planC = createStapleStruct(structNumV,probCutoff,structureName,planC) % function planC = createStapleStruct(structNumV,probCutoff,structureName,planC) % % Function to create STAPLE agreement structure at the passed probability % probCutoff. % % APA, 11/13/2017 if ~exist('planC','var') global planC end indexS = planC{end}; scanNum = getStructureAssociatedScan(structNumV(1),planC); numObs = length(structNumV); siz = getUniformScanSize(planC{indexS.scan}(scanNum)); rateMatM = false(prod(siz),numObs); for i=1:numObs mask3M = getUniformStr(structNumV(i),planC); rateMatM(:,i) = mask3M(:); end indV = sum(rateMatM,2) > 0; rateMatM = rateMatM(indV,:); iterlim=100; senstart=0.9999*ones(1,numObs); specstart=0.9999*ones(1,numObs); %[stapleV, sen, spec, Sall] = staple(rateMatM,iterlim, single(senstart), single(specstart)); [stapleV, sen, spec, Sall] = gpuStaple(rateMatM,iterlim, single(senstart), single(specstart)); staple3M = zeros(siz); staple3M(indV) = stapleV; newStrMask3M = staple3M >= probCutoff; planC = maskToCERRStructure(newStrMask3M, 1, scanNum, structureName, planC);
(* Calls to external decision procedures *) Require Export ZArith. Require Export Classical. (* Zenon *) (* Copyright 2004 INRIA *) (* $Id: Dp.v 12337 2009-09-17 15:58:14Z glondu $ *) Lemma zenon_nottrue : (~True -> False). Proof. tauto. Qed. Lemma zenon_noteq : forall (T : Type) (t : T), ((t <> t) -> False). Proof. tauto. Qed. Lemma zenon_and : forall P Q : Prop, (P -> Q -> False) -> (P /\ Q -> False). Proof. tauto. Qed. Lemma zenon_or : forall P Q : Prop, (P -> False) -> (Q -> False) -> (P \/ Q -> False). Proof. tauto. Qed. Lemma zenon_imply : forall P Q : Prop, (~P -> False) -> (Q -> False) -> ((P -> Q) -> False). Proof. tauto. Qed. Lemma zenon_equiv : forall P Q : Prop, (~P -> ~Q -> False) -> (P -> Q -> False) -> ((P <-> Q) -> False). Proof. tauto. Qed. Lemma zenon_notand : forall P Q : Prop, (~P -> False) -> (~Q -> False) -> (~(P /\ Q) -> False). Proof. tauto. Qed. Lemma zenon_notor : forall P Q : Prop, (~P -> ~Q -> False) -> (~(P \/ Q) -> False). Proof. tauto. Qed. Lemma zenon_notimply : forall P Q : Prop, (P -> ~Q -> False) -> (~(P -> Q) -> False). Proof. tauto. Qed. Lemma zenon_notequiv : forall P Q : Prop, (~P -> Q -> False) -> (P -> ~Q -> False) -> (~(P <-> Q) -> False). Proof. tauto. Qed. Lemma zenon_ex : forall (T : Type) (P : T -> Prop), (forall z : T, ((P z) -> False)) -> ((exists x : T, (P x)) -> False). Proof. firstorder. Qed. Lemma zenon_all : forall (T : Type) (P : T -> Prop) (t : T), ((P t) -> False) -> ((forall x : T, (P x)) -> False). Proof. firstorder. Qed. Lemma zenon_notex : forall (T : Type) (P : T -> Prop) (t : T), (~(P t) -> False) -> (~(exists x : T, (P x)) -> False). Proof. firstorder. Qed. Lemma zenon_notall : forall (T : Type) (P : T -> Prop), (forall z : T, (~(P z) -> False)) -> (~(forall x : T, (P x)) -> False). Proof. intros T P Ha Hb. apply Hb. intro. apply NNPP. exact (Ha x). Qed. Lemma zenon_equal_base : forall (T : Type) (f : T), f = f. Proof. auto. Qed. Lemma zenon_equal_step : forall (S T : Type) (fa fb : S -> T) (a b : S), (fa = fb) -> (a <> b -> False) -> ((fa a) = (fb b)). Proof. intros. rewrite (NNPP (a = b)). congruence. auto. Qed. Lemma zenon_pnotp : forall P Q : Prop, (P = Q) -> (P -> ~Q -> False). Proof. intros P Q Ha. rewrite Ha. auto. Qed. Lemma zenon_notequal : forall (T : Type) (a b : T), (a = b) -> (a <> b -> False). Proof. auto. Qed. Ltac zenon_intro id := intro id || let nid := fresh in (intro nid; clear nid) . Definition zenon_and_s := fun P Q a b => zenon_and P Q b a. Definition zenon_or_s := fun P Q a b c => zenon_or P Q b c a. Definition zenon_imply_s := fun P Q a b c => zenon_imply P Q b c a. Definition zenon_equiv_s := fun P Q a b c => zenon_equiv P Q b c a. Definition zenon_notand_s := fun P Q a b c => zenon_notand P Q b c a. Definition zenon_notor_s := fun P Q a b => zenon_notor P Q b a. Definition zenon_notimply_s := fun P Q a b => zenon_notimply P Q b a. Definition zenon_notequiv_s := fun P Q a b c => zenon_notequiv P Q b c a. Definition zenon_ex_s := fun T P a b => zenon_ex T P b a. Definition zenon_notall_s := fun T P a b => zenon_notall T P b a. Definition zenon_pnotp_s := fun P Q a b c => zenon_pnotp P Q c a b. Definition zenon_notequal_s := fun T a b x y => zenon_notequal T a b y x. (* Ergo *) Set Implicit Arguments. Section congr. Variable t:Type. Lemma ergo_eq_concat_1 : forall (P:t -> Prop) (x y:t), P x -> x = y -> P y. Proof. intros; subst; auto. Qed. Lemma ergo_eq_concat_2 : forall (P:t -> t -> Prop) (x1 x2 y1 y2:t), P x1 x2 -> x1 = y1 -> x2 = y2 -> P y1 y2. Proof. intros; subst; auto. Qed. End congr.
module Door import Effects data DoorState = Closed | Open data DoorInfo : DoorState -> Type where DI : DoorInfo s data Door : Effect where OpenDoor : sig Door () (DoorInfo Closed) (DoorInfo Open) CloseDoor : sig Door () (DoorInfo Open) (DoorInfo Closed) Knock : sig Door () (DoorInfo Closed) DOOR : DoorState -> EFFECT DOOR t = MkEff (DoorInfo t) Door openDoor : Eff () [DOOR Closed] [DOOR Open] openDoor = call OpenDoor closeDoor : Eff () [DOOR Open] [DOOR Closed] closeDoor = call CloseDoor knock : Eff () [DOOR Closed] knock = call Knock doorProg : Eff () [DOOR Closed] doorProg = do knock openDoor closeDoor
# Thoughts while solving a nasty integral *Nhat Le, Aug 4, 2017* Today, I had to solve an integral like this: $$\int_0^\infty x^N \ \exp\left(-Mx^2\right) \ \mathrm{d}x $$ It is probably solvable by parts, but being lazy and being a fan of Feynman, I decided to differentiate under the integral sign I started with the integral: \begin{align} \int_0^\infty x \ \exp\left(-Mx^2\right) \ \mathrm{d}x = \frac{-1}{2M} \ \left.\exp\left(-Mx^2\right) \right|_0^\infty = \frac{1}{2M} \end{align} Now comes the crucial step: I differentiated both sides *with respect to M*, several times... \begin{align} \int_0^\infty x^3 \ \exp\left(-Mx^2\right) \ \mathrm{d}x = \frac{1}{2M^2} \\[1em] \int_0^\infty x^5 \ \exp\left(-Mx^2\right) \ \mathrm{d}x = \frac{2}{2M^3} \\[1em] \int_0^\infty x^7 \ \exp\left(-Mx^2\right) \ \mathrm{d}x = \frac{6}{2M^4} \end{align} Have you noticed a pattern? It is easy to see (and trivial to prove by induction) that \begin{align} \int_0^\infty x^{2n-1} \ \exp\left(-Mx^2\right) \ \mathrm{d}x = \frac{(n-1)!}{2M^n} \end{align} We're done! (At least for the case $N$ is odd...) But the fun doesn't stop there. Let's put $M=1$ to get $$(n-1)! = 2\int_0^\infty x^{2n-1} \ \exp\left(-x^2\right) \ \mathrm{d}x$$ A simple change of variable $t=x^2$ gets us: $$(n-1)! = \int_0^\infty t^{n-1} \ \exp\left(-t\right) \ \mathrm{d}t$$ Guess what, the right hand side is exactly the Gamma function, which is the natural extension of the factorial function to real numbers. $$(n-1)! = \Gamma(n) = \int_0^\infty t^{n-1} \ e^{-t} \ \mathrm{d}t$$ And *that* is pretty amazing.
This notebook is part of the *orix* documentation https://orix.readthedocs.io. Links to the documentation won’t work from the notebook. # Crystal directions This notebook details how to perform operations with and plot directions with respect to the crystal reference system using Miller indices with the [orix.vector.Miller](reference.rst#orix.vector.Miller) class. Many of the initial examples, explaining basic crystallographic computations with crystal lattice directions $[uvw]$ and crystal lattice planes $(hkl)$, are taken from the textbook *Introduction to Conventional Transmission Electron Microscopy* (<cite data-cite="degraef2003introduction">De Graef (2003)</cite>). Some of the later examples are also inspired by MTEX' excellent documentation on [Miller indices](https://mtex-toolbox.github.io/CrystalDirections.html) and [operations with them](https://mtex-toolbox.github.io/CrystalOperations.html). ```python %matplotlib inline from diffpy.structure import Lattice, Structure import matplotlib.pyplot as plt import numpy as np from orix.crystal_map import Phase from orix.quaternion import Orientation, Rotation, symmetry from orix.vector import AxAngle, Miller, Vector3d plt.rcParams.update( { "figure.figsize": (7, 7), "font.size": 20, "axes.grid": True, "lines.markersize": 10, "lines.linewidth": 2, } ) ``` To start with, let's create a tetragonal crystal with lattice parameters $a$ = $b$ = 0.5 nm and $c$ = 1 nm and symmetry elements described by point group *4* ```python tetragonal = Phase( point_group="4", structure=Structure(lattice=Lattice(0.5, 0.5, 1, 90, 90, 90)) ) print(tetragonal) print(tetragonal.structure.lattice) ``` Here, the [Phase](reference.rst#orix.crystal_map.Phase) class attaches a point group symmetry, [Symmetry](reference.rst#orix.quaternion.Symmetry), to a [Structure](https://www.diffpy.org/diffpy.structure/package.html#diffpy.structure.structure.Structure) containing a [Lattice](https://www.diffpy.org/diffpy.structure/mod_lattice.html#diffpy.structure.lattice.Lattice) (where the crystal axes are defined), and possibly some [Atom](https://www.diffpy.org/diffpy.structure/mod_atom.html#diffpy.structure.atom.Atom)s. ## Directions $[uvw]$ A crystal lattice direction $\mathbf{m} = u \cdot \mathbf{a} + v \cdot \mathbf{b} + w \cdot \mathbf{c}$ is a vector with coordinates $u, v, w$ with respect to the crystal axes $\mathbf{a}, \mathbf{b}, \mathbf{c}$, and is denoted $[uvw]$. We can create a set of these Miller indices by passing a list/array/tuple to `uvw` in [Miller](reference.rst#orix.vector.Miller) ```python m1 = Miller(uvw=[[1, 2, 0], [3, 1, 1]], phase=tetragonal) m1.scatter(axes_labels=["x", "y", None], c=["b", "r"]) m1 ``` Here, we plotted the lattice directions in the stereographic projection using the [Vector3d.scatter()](reference.rst#orix.vector.Vector3d.scatter) plotting method, which also works for `Miller.scatter()` since the `Miller` class inherits most of the functionality in the `Vector3d` class. Let's compute the dot product in nanometres and the angle in degrees between the vectors ```python m1[0].dot(m1[1]) ``` ```python np.rad2deg(m1[0].angle_with(m1[1])) ``` The length of a direct lattice vector is available via the [Miller.length](reference.rst#orix.vector.Miller.length) property, given in lattice parameter units (nm in this case) ```python Miller(uvw=[0, -0.5, 0.5], phase=tetragonal).length ``` ## Planes $(hkl)$ A crystal lattice plane $(hkl)$ is described by its normal vector $\mathbf{n} = h\cdot\mathbf{a^*} + k\cdot\mathbf{b^*} + l\cdot\mathbf{c^*}$, where $\mathbf{a^*}, \mathbf{b^*}, \mathbf{c^*}$ are the reciprocal crystal axes. As for crystal directions $[uvw]$, we can create a set of these Miller indices by passing `hkl` instead of `uvw` to [Miller](reference.rst#orix.vector.Miller) ```python m2 = Miller(hkl=m1.uvw, phase=tetragonal) m2.scatter(c=["y", "g"], marker="*") m2 ``` Let's compute the angle in degrees between the lattice plane normals ```python np.rad2deg(m2[0].angle_with(m2[1])) ``` Note that the lattice plane normals $(hkl)$ are not always parallel to the lattice directions $[uvw]$, even if the indices are the same ```python fig = m1.scatter(return_figure=True, c=["b", "r"]) m2.scatter(figure=fig, c=["y", "g"], marker="*") ``` We can get the reciprocal components of the lattice vector [114] (i.e. which lattice plane the [114] direction is perpendicular to) by accessing [Miller.hkl](reference.rst#orix.vector.Miller.hkl) for a `Miller` object with crystal directions (or [Miller.uvw](reference.rst#orix.vector.Miller.uvw) for a `Miller` object with crystal plane normals) ```python Miller(uvw=[1, 1, 4], phase=tetragonal).hkl ``` We see that the lattice vector [114] is perpendicular to the lattice plane (1 1 16). The length of reciprocal lattice vectors can also be accessed via the `Miller.length` property, and equals $\left|\mathbf{g}_{\mathrm{hkl}}\right| = \frac{1}{d_{\mathrm{hkl}}}$ in reciprocal lattice parameter units (nm^-1 in this case), meaning we can obtain the interplanar spacing $d_{\mathrm{hkl}}$ ```python m2.length ``` ```python 1 / m2.length ``` ## Zone axes The cross product of the lattice vectors [110] and [111] in the tetragonal crystal, in direct space, is described by a vector expressed in reciprocal space, $(hkl)$ ```python m3 = Miller(uvw=[[1, 1, 0], [1, 1, 1]], phase=tetragonal) m3perp = m3[0].cross(m3[1]) m3perp ``` The exact "indices" are returned, however, we can get a new `Miller` instance with the indices rounded down or up to the *closest* smallest integer via the [Miller.round()](reference.rst#orix.vector.Miller.round) method ```python m3perp.round() ``` The maximum index that `Miller.round()` might return can be set by passing the `max_index` parameter. We can plot these direct lattice vectors $[uvw]$ and the vectors normal to the cross product vector, i.e. normal to the reciprocal lattice vector $(hkl)$ ```python fig = m3.scatter(return_figure=True, c="r") m3perp.draw_circle(figure=fig, color="b", linestyle="--") ``` Likewise, the cross product of reciprocal lattice vectors (110) and (111) results in a direct lattice vector ```python m4 = Miller(hkl=[[1, 1, 0], [1, 1, 1]], phase=tetragonal) m4perp = m4[0].cross(m4[1]).round() m4perp ``` ```python fig = m4.scatter(return_figure=True, c="b") m4perp.draw_circle(figure=fig, color="r", linestyle="--") ``` ## Trigonal and hexagonal index conventions Crystal lattice vectors and planes in lattices with trigonal and hexagonal crystal symmetry are typically expressed in Weber symbols $[UVTW]$ and Miller-Bravais indices $(hkil)$. The definition of $[UVTW]$ used in orix follows *Introduction to Conventional Transmission Electron Microscopy* (DeGraef, 2003) \begin{align} U &= \frac{2u - v}{3},\\ V &= \frac{2v - u}{3},\\ T &= -\frac{u + v}{3},\\ W &= w. \end{align} For a plane, the $h$, $k$ and $l$ indices are the same in $(hkl)$ and $(hkil)$, and $i = -(h + k)$. The first three Miller indices always sum up to zero, i.e. \begin{align} U + V + T &= 0,\\ h + k + i &= 0. \end{align} ```python trigonal = Phase( point_group="321", structure=Structure(lattice=Lattice(4.9, 4.9, 5.4, 90, 90, 120)) ) trigonal ``` ```python m5 = Miller(UVTW=[2, 1, -3, 1], phase=trigonal) m5 ``` ```python m6 = Miller(hkil=[1, 1, -2, 3], phase=trigonal) m6 ``` ```python fig = m5.scatter(return_figure=True, c="C0", grid_resolution=(30, 30)) m6.scatter(figure=fig, c="C1") ``` One can change the coordinate format of the Miller class, however this does not change the vector, since all vectors are stored with respect to the cartesian coordinate system internally ```python print(m6, "\n\n", m6.data) ``` ```python m6.coordinate_format = "UVTW" print(m6, "\n\n", m6.data) ``` Getting the closest integer indices, however, changes the vector ```python m6round = m6.round() print(m6round, "\n\n", m6round.data) ``` ## Symmetrically equivalent directions and planes The point group symmetry elements of the crystal lattice can be applied to to describe symmetrically equivalent crystal directions and planes. This applies to crystals in all seven systems, but we'll use the cubic crystal as an example because of its high symmetry ```python cubic = Phase(point_group="m-3m", structure=Structure()) print(cubic, "\n", cubic.structure.lattice.abcABG()) ``` The directions parallel to the crystal axes ($\mathbf{a}$, $\mathbf{b}$, $\mathbf{c}$) given by $[100]$, $[\bar{1}00]$, $[010]$, $[0\bar{1}0]$, $[001]$, and $[00\bar{1}]$ ($\bar{1}$ means "-1") are symmetrically equivalent, and can be obtained using [Miller.symmetrise()](reference.rst#orix.vector.Miller.symmetrise) ```python m7 = Miller(uvw=[1, 0, 0], phase=cubic) m7.symmetrise(unique=True) ``` Without passing `unique=True`, since the cubic crystal symmetry is described by 48 symmetry operations (or elements), 48 directions would have been returned. These six directions, known as a family, may be expressed collectively as $\left<100\right>$, the brackets implying all six permutations or variants of 1, 0, 0. This particular family is said to have a multiplicity of 6 ```python m7.multiplicity ``` ```python m8 = Miller(uvw=[[1, 0, 0], [1, 1, 0], [1, 1, 1]], phase=cubic) m8 ``` ```python m8.multiplicity ``` Let's plot the symmetrically equivalent directions from the direction families $\left<100\right>$, $\left<110\right>$, and $\left<111\right>$ impinging on the upper hemisphere. By also returning the indices of which family each symmetrically equivalent direction belongs to from `Miller.symmetrise()`, we can give a unique color per family ```python m9, idx = m8.symmetrise(unique=True, return_index=True) fig = m9[idx == 0].scatter(c="C0", return_figure=True) for i in range(1, m9.size): m9[idx == i].scatter(c=f"C{i}", figure=fig) ``` Similarly, symmetrically equivalent planes $(hkl)$ can be collectively expressed as planes of the form $\{hkl\}$ ```python m10 = Miller(hkl=[[1, 0, 0], [1, 1, 0], [1, 1, 1]], phase=cubic) m10.multiplicity ``` ```python fig = m10[0].symmetrise(unique=True).scatter(c="C0", return_figure=True) for i in range(1, m10.size): m10[i].symmetrise(unique=True).scatter(c=f"C{i}", figure=fig) ``` We computed the angles between directions and plane normals earlier in this notebook. In general, [Miller.angle_with()](reference.rst#orix.vector.Miller.angle_with) does not consider symmetrically equivalent directions, unless `use_symmetry=True` is passed. Consider $(100)$ and $(\bar{1}00)$ and $(111)$ and $(\bar{1}11)$ in the stereographic plot above ```python m11 = Miller(hkl=[[1, 0, 0], [1, 1, 1]], phase=cubic) m12 = Miller(hkl=[[-1, 0, 0], [-1, 1, 1]], phase=cubic) ``` ```python np.rad2deg(m11.angle_with(m12)) ``` ```python np.rad2deg(m11.angle_with(m12, use_symmetry=True)) ``` Thus, passing `use_symmetry=True` ensures that the smallest angles between `m11` and the symmetrically equivalent directions to `m12` are found. ## Directions and planes in rotated crystals Let's consider the orientation of a cubic crystal rotated $45^{\circ}$ about the sample $\mathbf{Z}$ axis. Orientations in `orix` are defined as rotations from the sample to the crystal (so-called "lab2crystal"), so we have to invert the orientation to get the vector expressed in the sample reference frame. Furthermore, as per the discussion by <cite data-cite="rowenhorst2015consistent">Rowenhorst et al. (2015)</cite>, the axis-angle representation of a $45^{\circ}$ rotation about the sample $\mathbf{Z}$ is written as $(\mathbf{\hat{n}}, \omega) = ([00\bar{1},90^{\circ})$ ```python o = Orientation.from_axes_angles((0, 0, -1), np.deg2rad(45), symmetry=cubic.point_group) o ``` We can apply this orientation to a crystal direction $[uvw]$ to find this direction in this particular crystal with respect to the sample coordinate system ```python m12 = Miller(uvw=[1, 1, 1], phase=cubic) ~o * m12 ``` ```python # [uvw] in unrotated crystal fig = m12.scatter(c="r", return_figure=True, axes_labels=["X", "Y", "Z"]) # [uvw] in rotated crystal (~o * m12).scatter(figure=fig, c="b", marker="x") ``` We see that the $[111]$ vector in the crystal is aligned with the sample $\mathbf{Y}$ direction. We can apply the crystal symmetry to obtain the coordinates with respect to the sample reference frame for all crystallographically equivalent directions ```python (~o * m12.symmetrise(unique=True)).scatter(c="b", marker="x") ``` ```python o2 = Orientation.from_euler(np.deg2rad([10, 20, 30]), symmetry=trigonal.point_group) o2 ``` ```python m13 = Miller(hkil=[1, -1, 0, 0], phase=trigonal) m13 ``` ```python p = ~o2 * m13.symmetrise(unique=True) p.scatter( hemisphere="both", grid_resolution=(30, 30), figure_kwargs=dict(figsize=(10, 5)), axes_labels=["X", "Y", "Z"], ) ``` The stereographic plots above are essentially the $\{1\bar{1}00\}$ pole figure representation of the orientation $O_2$. ___ ## A diamond [111] pole figure Let's make a pole figure in the [111] direction of the diamond structure, as seen in [this figure from Wikipedia](https://commons.wikimedia.org/wiki/File:DiamondPoleFigure111.png). The figure caption reads as follows > *The spots in the stereographic projection show the orientation of lattice planes with the 111 in the center. Only poles for a non-forbidden Bragg reflection are shown between Miller indices -10 <= (h,k,l) <= 10. The green spots contain Miller indices up to 3, for example 111, 113, 133, 200 etc in its fundamental order. Red are those raising to 5, ex. 115, 135, 335 etc, while blue are all remaining until 10, such as 119, 779, 10.10.00 etc.* ```python diamond = Phase(space_group=227) md = Miller.from_highest_indices(phase=diamond, uvw=[10, 10, 10]) md ``` Remove duplicates under symmetry using [Miller.unique()](reference.rst#orix.vector.Miller.unique) ```python md2 = md.unique(use_symmetry=True) md2.size ``` Symmetrise to get all symmetrically equivalent directions ```python md3 = md2.symmetrise(unique=True) md3 ``` Remove forbidden reflections in face-centered cubic structures (all hkl must be all even or all odd) ```python selection = np.sum(np.mod(md3.hkl, 2), axis=1) allowed = np.array([i not in [1, 2] for i in selection], dtype=bool) md4 = md3[allowed] md4 ``` Assign colors to each class of vectors as per the description on Wikipedia ```python uvw = np.abs(md4.uvw) green = np.all(uvw <= 3, axis=-1) red = np.any(uvw > 3, axis=-1) * np.all(uvw <= 5, axis=-1) blue = np.any(uvw > 5, axis=-1) rgb_mask = np.column_stack([red, green, blue]) # Sanity check print(np.count_nonzero(rgb_mask) == md4.size) ``` Rotate directions so that [111] impinges the unit sphere in the north pole (out of plane direction) ```python vz = Vector3d.zvector() v111 = Vector3d([1, 1, 1]) r1 = Rotation.from_neo_euler( AxAngle.from_axes_angles(v111.cross(vz), v111.angle_with(vz).data) ) r2 = Rotation.from_neo_euler(AxAngle.from_axes_angles(vz, np.deg2rad(-15))) md5 = r2 * r1 * md4 ``` Restrict to upper hemisphere and remove duplicates ```python is_upper = md5.z > 0 md6 = md5[is_upper] rgb_mask2 = rgb_mask[is_upper] _, idx = md6.unit.unique(return_index=True) md7 = md6[idx] rgb_mask2 = rgb_mask2[idx] ``` Finally, plot the vectors ```python rgb = np.zeros_like(md7.uvw) rgb[rgb_mask2] = 1 md7.scatter(c=rgb, s=10, grid=False, figure_kwargs=dict(figsize=(12, 12))) ```
#include <blitzcommon/StringUtils.h> namespace blitz { size_t lastIndexOf(const char* str, const char chr) { int idx = 0; int lastIdx = -1; while (true) { if (str[idx] == '\0') { return lastIdx; } if (str[idx] == chr) { lastIdx = idx; } ++idx; }; }; char* copyStr(const char* toCpy) { const auto len = strlen(toCpy); char* copied = new char[len + 1]; strncpy(copied, toCpy, len); copied[len] = '\0'; return copied; } string::string(const char* str) : strPtr(str) { length = strlen(str); strHash = hashString(strPtr); } size_t string::getLength() const { return length; } string::operator const char*() const { return strPtr; } bool string::operator==(const string& rhs) const { return strHash == rhs.strHash; } char string::operator[](const size_t idx) const { return strPtr[idx]; } hash string::getHash() const { return strHash; } } // namespace blitz
lemma AE_count_space: "(AE x in count_space A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P x)"
Formal statement is: lemma limitin_const: "limitin euclidean (\<lambda>a. l) l F" Informal statement is: The constant function $f(x) = l$ is a limit of the sequence $F$ in the Euclidean topology.
/- Copyright (c) 2019 Neil Strickland. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Neil Strickland We define the monoid of self-maps of a type, and show that monoid homomorphisms `M → (self_map X)` give actions of `M` on `X`. -/ import algebra.group group_theory.group_action variable (T : Type*) def self_map (T : Type*) : Type* := (T → T) instance [fintype T] [decidable_eq T] : fintype (self_map T) := by {dsimp[self_map],apply_instance} instance [fintype T] [decidable_eq T] : decidable_eq (self_map T) := by {dsimp[self_map],apply_instance} instance self_map_monoid (T : Type*) : monoid (self_map T) := { mul := λ f g x, f (g x), mul_assoc := λ f g h, by {funext,refl}, one := λ x, x, one_mul := λ f, by {funext,refl}, mul_one := λ f, by {funext,refl}, } namespace self_map @[simp] lemma one_app (t : T) : (1 : self_map T) t = t := rfl @[simp] lemma mul_app (f g : self_map T) (t : T) : (f * g) t = f (g t) := rfl def units_equiv : units (self_map T) ≃ equiv.perm T := { to_fun := λ u, equiv.mk u.val u.inv (begin intro x, change (u.inv * u.val) x = x, rw[u.inv_val], refl, end) (begin intro x, change (u.val * u.inv) x = x, rw[u.val_inv], refl, end), inv_fun := λ v, units.mk v.to_fun v.inv_fun (by {funext,exact v.right_inv x}) (by {funext,exact v.left_inv x}), left_inv := λ u,begin ext,refl, end, right_inv := λ v,begin ext,refl end } variable {T} instance : mul_action (self_map T) T := { smul := λ f x, f x, one_smul := λ x, rfl, mul_smul := λ f g x, rfl } def mul_action_of_hom {M X : Type*} [monoid M] (act : M →* self_map X) : mul_action M X := @mul_action.mk M X _ ⟨λ m x, (act m) x⟩ (λ x,by { change (act 1) x = x, rw[act.map_one], refl }) (λ m n x,by {change act (m * n) x = act m (act n x), rw[act.map_mul], refl}) end self_map
[STATEMENT] lemma less_Suc [simp] : "n \<le> k \<Longrightarrow> (k < Suc n) = (k = n)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. n \<le> k \<Longrightarrow> (k < Suc n) = (k = n) [PROOF STEP] by arith
[STATEMENT] lemma ok_0_atms: "ok 0 mr \<Longrightarrow> regex.atms (from_mregex mr []) = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. ok 0 mr \<Longrightarrow> regex.atms (from_mregex mr []) = {} [PROOF STEP] by (induct mr) auto
(* Title: HOL/HOLCF/IOA/Storage/Action.thy Author: Olaf Müller *) section \<open>The set of all actions of the system\<close> theory Action imports MainRLT begin datatype action = New | Loc nat | Free nat lemma [cong]: "\<And>x. x = y \<Longrightarrow> case_action a b c x = case_action a b c y" by simp end
State Before: R : Type u_3 A : Type u_2 T : Type ?u.47893 B : Type u_1 ι : Type ?u.47899 inst✝¹¹ : SemilatticeSup B inst✝¹⁰ : OrderBot B inst✝⁹ : SemilatticeInf T inst✝⁸ : OrderTop T inst✝⁷ : Semiring R inst✝⁶ : AddMonoid A inst✝⁵ : AddMonoid B inst✝⁴ : CovariantClass B B (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝³ : CovariantClass B B (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝² : AddMonoid T inst✝¹ : CovariantClass T T (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝ : CovariantClass T T (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 degb : A → B degt : A → T degb0 : degb 0 ≤ 0 degbm : ∀ (a b : A), degb (a + b) ≤ degb a + degb b n : ℕ f : AddMonoidAlgebra R A ⊢ Finset.sup (f ^ n).support degb ≤ n • Finset.sup f.support degb State After: R : Type u_3 A : Type u_2 T : Type ?u.47893 B : Type u_1 ι : Type ?u.47899 inst✝¹¹ : SemilatticeSup B inst✝¹⁰ : OrderBot B inst✝⁹ : SemilatticeInf T inst✝⁸ : OrderTop T inst✝⁷ : Semiring R inst✝⁶ : AddMonoid A inst✝⁵ : AddMonoid B inst✝⁴ : CovariantClass B B (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝³ : CovariantClass B B (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝² : AddMonoid T inst✝¹ : CovariantClass T T (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝ : CovariantClass T T (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 degb : A → B degt : A → T degb0 : degb 0 ≤ 0 degbm : ∀ (a b : A), degb (a + b) ≤ degb a + degb b n : ℕ f : AddMonoidAlgebra R A ⊢ Finset.sup (List.prod (List.replicate n f)).support degb ≤ List.sum (List.replicate n (Finset.sup f.support degb)) Tactic: rw [← List.prod_replicate, ← List.sum_replicate] State Before: R : Type u_3 A : Type u_2 T : Type ?u.47893 B : Type u_1 ι : Type ?u.47899 inst✝¹¹ : SemilatticeSup B inst✝¹⁰ : OrderBot B inst✝⁹ : SemilatticeInf T inst✝⁸ : OrderTop T inst✝⁷ : Semiring R inst✝⁶ : AddMonoid A inst✝⁵ : AddMonoid B inst✝⁴ : CovariantClass B B (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝³ : CovariantClass B B (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝² : AddMonoid T inst✝¹ : CovariantClass T T (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝ : CovariantClass T T (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 degb : A → B degt : A → T degb0 : degb 0 ≤ 0 degbm : ∀ (a b : A), degb (a + b) ≤ degb a + degb b n : ℕ f : AddMonoidAlgebra R A ⊢ Finset.sup (List.prod (List.replicate n f)).support degb ≤ List.sum (List.replicate n (Finset.sup f.support degb)) State After: R : Type u_3 A : Type u_2 T : Type ?u.47893 B : Type u_1 ι : Type ?u.47899 inst✝¹¹ : SemilatticeSup B inst✝¹⁰ : OrderBot B inst✝⁹ : SemilatticeInf T inst✝⁸ : OrderTop T inst✝⁷ : Semiring R inst✝⁶ : AddMonoid A inst✝⁵ : AddMonoid B inst✝⁴ : CovariantClass B B (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝³ : CovariantClass B B (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝² : AddMonoid T inst✝¹ : CovariantClass T T (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝ : CovariantClass T T (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 degb : A → B degt : A → T degb0 : degb 0 ≤ 0 degbm : ∀ (a b : A), degb (a + b) ≤ degb a + degb b n : ℕ f : AddMonoidAlgebra R A ⊢ List.sum (List.map (fun f => Finset.sup f.support degb) (List.replicate n f)) = List.sum (List.replicate n (Finset.sup f.support degb)) Tactic: refine' (sup_support_list_prod_le degb0 degbm _).trans_eq _ State Before: R : Type u_3 A : Type u_2 T : Type ?u.47893 B : Type u_1 ι : Type ?u.47899 inst✝¹¹ : SemilatticeSup B inst✝¹⁰ : OrderBot B inst✝⁹ : SemilatticeInf T inst✝⁸ : OrderTop T inst✝⁷ : Semiring R inst✝⁶ : AddMonoid A inst✝⁵ : AddMonoid B inst✝⁴ : CovariantClass B B (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝³ : CovariantClass B B (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝² : AddMonoid T inst✝¹ : CovariantClass T T (fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 inst✝ : CovariantClass T T (Function.swap fun x x_1 => x + x_1) fun x x_1 => x ≤ x_1 degb : A → B degt : A → T degb0 : degb 0 ≤ 0 degbm : ∀ (a b : A), degb (a + b) ≤ degb a + degb b n : ℕ f : AddMonoidAlgebra R A ⊢ List.sum (List.map (fun f => Finset.sup f.support degb) (List.replicate n f)) = List.sum (List.replicate n (Finset.sup f.support degb)) State After: no goals Tactic: rw [List.map_replicate]
//============================================================================== // Copyright 2003 - 2012 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2012 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #ifndef BOOST_SIMD_SDK_SIMD_EXTENSIONS_COMMON_COMMON_HPP_INCLUDED #define BOOST_SIMD_SDK_SIMD_EXTENSIONS_COMMON_COMMON_HPP_INCLUDED #include <boost/detail/workaround.hpp> #if !defined(BOOST_SIMD_DETECTED) #define BOOST_SIMD_NO_SIMD #define BOOST_SIMD_BYTES 16 #define BOOST_SIMD_BITS 128 #define BOOST_SIMD_STRING "simd_emulation" #define BOOST_SIMD_CARDINALS (2)(4)(8)(16) #define BOOST_SIMD_DEFAULT_EXTENSION ::boost::simd::tag::simd_emulation_<16u> #define BOOST_SIMD_DEFAULT_SITE ::boost::dispatch::tag::cpu_ #include <boost/simd/sdk/config/types.hpp> #if !defined(BOOST_SIMD_SIMD_TYPES) #include <boost/simd/sdk/simd/extensions/x86/types.hpp> #endif #endif #include <boost/simd/sdk/memory/aligned_array.hpp> #include <boost/simd/sdk/config.hpp> #endif
lemma finite_set_avoid: fixes a :: "'a::metric_space" assumes "finite S" shows "\<exists>d>0. \<forall>x\<in>S. x \<noteq> a \<longrightarrow> d \<le> dist a x"
module Erlang.Decode import Erlang.Conversion import Erlang.IO import Erlang.Types %default total -- This module contains functions to turn an untyped Erlang value into a -- typed Idris value. -- The decoding functions are commonly used together with `erlCall` and -- `erlUnsafeCall`. ||| The possible errors that can happen when decoding an Erlang value. public export data ErlDecoderError = Error String | OneOf ErlDecoderError ErlDecoderError | Empty ||| The decoder type. export data ErlDecoder a = MkDecoder (ErlTerm -> Either ErlDecoderError a) namespace ErlDecoders ||| A list of decoders. public export data ErlDecoders : List Type -> Type where Nil : ErlDecoders [] (::) : ErlDecoder a -> ErlDecoders as -> ErlDecoders (a :: as) ||| A type describing how to decode an entry in an Erlang map. public export data ErlMapEntryDecoder : key -> Type -> Type where MkDecoderMapEntry : (key : a) -> ErlDecoder value -> ErlMapEntryDecoder key value ||| Convenience operator for creating an `MkDecoderMapEntry`. ||| ||| `"name" := string` is equivalent to `MkDecoderMapEntry "name" string` public export (:=) : (key : a) -> ErlDecoder value -> ErlMapEntryDecoder key value (:=) = MkDecoderMapEntry namespace ErlMapDecoders ||| A list describing how to decode entries in an Erlang map. public export data ErlMapDecoders : List ErlMapEntry -> Type where Nil : ErlMapDecoders [] (::) : ErlMapEntryDecoder key valueTy -> ErlMapDecoders xs -> ErlMapDecoders (MkMapEntry key valueTy :: xs) -- IMPLEMENTATIONS FOR `ErlDecoder` export Functor ErlDecoder where map f (MkDecoder valueDecoder) = MkDecoder (\term => either Left (Right . f) (valueDecoder term)) export Applicative ErlDecoder where pure value = MkDecoder (\_ => Right value) (MkDecoder fDecoder) <*> (MkDecoder valueDecoder) = MkDecoder (\term => do f <- fDecoder term value <- valueDecoder term pure (f value)) export Monad ErlDecoder where (MkDecoder valueDecoder) >>= f = MkDecoder (\term => do value <- valueDecoder term let (MkDecoder nextDecoder) = f value nextDecoder term) export Alternative ErlDecoder where empty = MkDecoder (\_ => Left Empty) (MkDecoder decoder1) <|> (MkDecoder decoder2) = MkDecoder (\term => case decoder1 term of Right res => Right res Left firstErr => case decoder2 term of Right res => Right res Left secondErr => Left (OneOf firstErr secondErr)) -- DECODE ERLANG TERM ||| Try to decode the given value using the given decoder. ||| Returns an `ErlDecoderError` in the case of failure. export erlDecode : ErlType from => ErlDecoder a -> from -> Either ErlDecoderError a erlDecode (MkDecoder decoder) term = decoder (cast term) ||| Try to decode the given value using the given decoder. ||| Returns `Nothing` in the case of failure. export erlDecodeMay : ErlType from => ErlDecoder a -> from -> Maybe a erlDecodeMay decoder term = case erlDecode decoder term of Right res => Just res Left _ => Nothing ||| Try to decode the given value using the given decoder. ||| Returns a default value in the case of failure. export erlDecodeDef : ErlType from => Lazy a -> ErlDecoder a -> from -> a erlDecodeDef def decoder term = case erlDecode decoder term of Right res => res Left _ => def -- PRIMITIVES %extern prim__erlMatchExact : ErlTerm -> ErlTerm -> Int %extern prim__erlDecodeCodepoint : ErlTerm -> Maybe Char %extern prim__erlDecodeInteger : ErlTerm -> Maybe Integer %extern prim__erlDecodeDouble : ErlTerm -> Maybe Double %extern prim__erlDecodeAtom : ErlTerm -> Maybe ErlAtom %extern prim__erlDecodeBinary : ErlTerm -> Maybe String %extern prim__erlDecodePid : ErlTerm -> Maybe ErlPid %extern prim__erldecodeReference : ErlTerm -> Maybe ErlReference %extern prim__erlDecodePort : ErlTerm -> Maybe ErlPort %extern prim__erlDecodeAnyMap : ErlTerm -> Maybe ErlAnyMap %extern prim__erlDecodeAnyList : ErlTerm -> Maybe ErlTerm %extern prim__erlDecodeNil : ErlTerm -> Maybe ErlNil %extern prim__erlDecodeCons : ErlTerm -> Maybe (ErlCons ErlTerm ErlTerm) %extern prim__erlDecodeTuple0 : ErlTerm -> Maybe ErlTuple0 %extern prim__erlDecodeTuple1 : ErlTerm -> Maybe (ErlTuple1 ErlTerm) %extern prim__erlDecodeTuple2 : ErlTerm -> Maybe (ErlTuple2 ErlTerm ErlTerm) %extern prim__erlDecodeTuple3 : ErlTerm -> Maybe (ErlTuple3 ErlTerm ErlTerm ErlTerm) %extern prim__erlDecodeTuple4 : ErlTerm -> Maybe (ErlTuple4 ErlTerm ErlTerm ErlTerm ErlTerm) %extern prim__erlDecodeTuple5 : ErlTerm -> Maybe (ErlTuple5 ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm) %extern prim__erlDecodeTuple6 : ErlTerm -> Maybe (ErlTuple6 ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm) %extern prim__erlDecodeTuple7 : ErlTerm -> Maybe (ErlTuple7 ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm) %extern prim__erlDecodeTuple8 : ErlTerm -> Maybe (ErlTuple8 ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm ErlTerm) %extern prim__erlDecodeFun0 : ErlTerm -> Maybe (ErlIOFun0 ErlTerm) %extern prim__erlDecodeFun1 : ErlTerm -> Maybe (ErlIOFun1 a ErlTerm) %extern prim__erlDecodeFun2 : ErlTerm -> Maybe (ErlIOFun2 a b ErlTerm) %extern prim__erlDecodeFun3 : ErlTerm -> Maybe (ErlIOFun3 a b c ErlTerm) %extern prim__erlDecodeFun4 : ErlTerm -> Maybe (ErlIOFun4 a b c d ErlTerm) %extern prim__erlDecodeFun5 : ErlTerm -> Maybe (ErlIOFun5 a b c d e ErlTerm) %extern prim__erlDecodeFun6 : ErlTerm -> Maybe (ErlIOFun6 a b c d e f ErlTerm) %extern prim__erlDecodeFun7 : ErlTerm -> Maybe (ErlIOFun7 a b c d e f g ErlTerm) %extern prim__erlDecodeFun8 : ErlTerm -> Maybe (ErlIOFun8 a b c d e f g h ErlTerm) -- DECODERS ||| Decoder that always fails, with the given error message. export fail : String -> ErlDecoder a fail msg = MkDecoder (\term => Left (Error msg)) ||| Decoder that always succeeds. export any : ErlDecoder ErlTerm any = MkDecoder (\term => Right term) ||| Decoder that always succeeds, where the success value is turned into ||| `Just value` and failure is turned into `Nothing`. export optional : ErlDecoder a -> ErlDecoder (Maybe a) optional decoder = map Just decoder <|> pure Nothing infixr 2 `lazyAlt` ||| A lazy version of `<|>` lazyAlt : ErlDecoder a -> Lazy (ErlDecoder a) -> ErlDecoder a lazyAlt decoder1 decoder2 = do result <- optional decoder1 case result of Just value => pure value Nothing => decoder2 ||| Decoder that expects an exact value. export exact : ErlType a => a -> ErlDecoder a exact matchValue = MkDecoder (\term => if prim__erlMatchExact term (cast matchValue) == 1 then Right matchValue else Left (Error "Expected the value to match exactly")) ||| Decoder that expects a codepoint value. export codepoint : ErlDecoder Char codepoint = MkDecoder (maybe (Left (Error "Expected a char")) Right . prim__erlDecodeCodepoint) ||| Decoder that expects an Erlang integer value. export integer : ErlDecoder Integer integer = MkDecoder (maybe (Left (Error "Expected an integer")) Right . prim__erlDecodeInteger) ||| Decoder that expects a Erlang float value. export double : ErlDecoder Double double = MkDecoder (maybe (Left (Error "Expected a double")) Right . prim__erlDecodeDouble) ||| Decoder that expects an Erlang atom value. export atom : ErlDecoder ErlAtom atom = MkDecoder (maybe (Left (Error "Expected an atom")) Right . prim__erlDecodeAtom) ||| Decoder that expects an Erlang binary value. export string : ErlDecoder String string = MkDecoder (maybe (Left (Error "Expected a binary")) Right . prim__erlDecodeBinary) ||| Decoder that expects a Erlang PID value. export pid : ErlDecoder ErlPid pid = MkDecoder (maybe (Left (Error "Expected a pid")) Right . prim__erlDecodePid) ||| Decoder that expects an Erlang reference value. export reference : ErlDecoder ErlReference reference = MkDecoder (maybe (Left (Error "Expected a reference")) Right . prim__erldecodeReference) ||| Decoder that expects an Erlang port value. export port : ErlDecoder ErlPort port = MkDecoder (maybe (Left (Error "Expected a port")) Right . prim__erlDecodePort) ||| Decoder that expects any Erlang map. export anyMap : ErlDecoder ErlAnyMap anyMap = MkDecoder (maybe (Left (Error "Expected a map")) Right . prim__erlDecodeAnyMap) ||| Decoder that expects any Erlang list. ||| ||| The list may either be the empty list or a list with a head and a tail. export anyList : ErlDecoder ErlTerm anyList = MkDecoder (maybe (Left (Error "Expected a list")) Right . prim__erlDecodeAnyList) ||| Decoder that expects an Erlang empty list. export nil : ErlDecoder ErlNil nil = MkDecoder (maybe (Left (Error "Expected a nil value")) Right . prim__erlDecodeNil) ||| Decoder that expects an Erlang list with a head and a tail. export cons : ErlDecoder a -> ErlDecoder b -> ErlDecoder (ErlCons a b) cons (MkDecoder xDecoder) (MkDecoder yDecoder) = MkDecoder (\term => do let Just (x :: y) = prim__erlDecodeCons term | Nothing => Left (Error "Expected a cons value") xRes <- xDecoder x yRes <- yDecoder y pure (xRes :: yRes)) ||| Decoder that expects a tuple of size 0. export tuple0 : ErlDecoder ErlTuple0 tuple0 = MkDecoder (maybe (Left (Error "Expected a tuple with 0 elements")) Right . prim__erlDecodeTuple0) ||| Decoder that expects a tuple of size 1, where each element in the tuple must ||| match the given decoder. export tuple1 : ErlDecoder a -> ErlDecoder (ErlTuple1 a) tuple1 (MkDecoder aDecoder) = MkDecoder (\term => do let Just (MkTuple1 a) = prim__erlDecodeTuple1 term | Nothing => Left (Error "Expected a tuple with 1 element") pure (MkTuple1 !(aDecoder a))) ||| Decoder that expects a tuple of size 2, where each element in the tuple must ||| match the given decoder. export tuple2 : ErlDecoder a -> ErlDecoder b -> ErlDecoder (ErlTuple2 a b) tuple2 (MkDecoder aDecoder) (MkDecoder bDecoder) = MkDecoder (\term => do let Just (MkTuple2 a b) = prim__erlDecodeTuple2 term | Nothing => Left (Error "Expected a tuple with 2 elements") pure (MkTuple2 !(aDecoder a) !(bDecoder b))) ||| Decoder that expects a tuple of size 3, where each element in the tuple must ||| match the given decoder. export tuple3 : ErlDecoder a -> ErlDecoder b -> ErlDecoder c -> ErlDecoder (ErlTuple3 a b c) tuple3 (MkDecoder aDecoder) (MkDecoder bDecoder) (MkDecoder cDecoder) = MkDecoder (\term => do let Just (MkTuple3 a b c) = prim__erlDecodeTuple3 term | Nothing => Left (Error "Expected a tuple with 3 elements") pure (MkTuple3 !(aDecoder a) !(bDecoder b) !(cDecoder c))) ||| Decoder that expects a tuple of size 4, where each element in the tuple must ||| match the given decoder. export tuple4 : ErlDecoder a -> ErlDecoder b -> ErlDecoder c -> ErlDecoder d -> ErlDecoder (ErlTuple4 a b c d) tuple4 (MkDecoder aDecoder) (MkDecoder bDecoder) (MkDecoder cDecoder) (MkDecoder dDecoder) = MkDecoder (\term => do let Just (MkTuple4 a b c d) = prim__erlDecodeTuple4 term | Nothing => Left (Error "Expected a tuple with 4 elements") pure (MkTuple4 !(aDecoder a) !(bDecoder b) !(cDecoder c) !(dDecoder d))) ||| Decoder that expects a tuple of size 5, where each element in the tuple must ||| match the given decoder. export tuple5 : ErlDecoder a -> ErlDecoder b -> ErlDecoder c -> ErlDecoder d -> ErlDecoder e -> ErlDecoder (ErlTuple5 a b c d e) tuple5 (MkDecoder aDecoder) (MkDecoder bDecoder) (MkDecoder cDecoder) (MkDecoder dDecoder) (MkDecoder eDecoder) = MkDecoder (\term => do let Just (MkTuple5 a b c d e) = prim__erlDecodeTuple5 term | Nothing => Left (Error "Expected a tuple with 5 elements") pure (MkTuple5 !(aDecoder a) !(bDecoder b) !(cDecoder c) !(dDecoder d) !(eDecoder e))) ||| Decoder that expects a tuple of size 6, where each element in the tuple must ||| match the given decoder. export tuple6 : ErlDecoder a -> ErlDecoder b -> ErlDecoder c -> ErlDecoder d -> ErlDecoder e -> ErlDecoder f -> ErlDecoder (ErlTuple6 a b c d e f) tuple6 (MkDecoder aDecoder) (MkDecoder bDecoder) (MkDecoder cDecoder) (MkDecoder dDecoder) (MkDecoder eDecoder) (MkDecoder fDecoder) = MkDecoder (\term => do let Just (MkTuple6 a b c d e f) = prim__erlDecodeTuple6 term | Nothing => Left (Error "Expected a tuple with 6 elements") pure (MkTuple6 !(aDecoder a) !(bDecoder b) !(cDecoder c) !(dDecoder d) !(eDecoder e) !(fDecoder f))) ||| Decoder that expects a tuple of size 6, where each element in the tuple must ||| match the given decoder. export tuple7 : ErlDecoder a -> ErlDecoder b -> ErlDecoder c -> ErlDecoder d -> ErlDecoder e -> ErlDecoder f -> ErlDecoder g -> ErlDecoder (ErlTuple7 a b c d e f g) tuple7 (MkDecoder aDecoder) (MkDecoder bDecoder) (MkDecoder cDecoder) (MkDecoder dDecoder) (MkDecoder eDecoder) (MkDecoder fDecoder) (MkDecoder gDecoder) = MkDecoder (\term => do let Just (MkTuple7 a b c d e f g) = prim__erlDecodeTuple7 term | Nothing => Left (Error "Expected a tuple with 7 elements") pure (MkTuple7 !(aDecoder a) !(bDecoder b) !(cDecoder c) !(dDecoder d) !(eDecoder e) !(fDecoder f) !(gDecoder g))) ||| Decoder that expects a tuple of size 7, where each element in the tuple must ||| match the given decoder. export tuple8 : ErlDecoder a -> ErlDecoder b -> ErlDecoder c -> ErlDecoder d -> ErlDecoder e -> ErlDecoder f -> ErlDecoder g -> ErlDecoder h -> ErlDecoder (ErlTuple8 a b c d e f g h) tuple8 (MkDecoder aDecoder) (MkDecoder bDecoder) (MkDecoder cDecoder) (MkDecoder dDecoder) (MkDecoder eDecoder) (MkDecoder fDecoder) (MkDecoder gDecoder) (MkDecoder hDecoder) = MkDecoder (\term => do let Just (MkTuple8 a b c d e f g h) = prim__erlDecodeTuple8 term | Nothing => Left (Error "Expected a tuple with 8 elements") pure (MkTuple8 !(aDecoder a) !(bDecoder b) !(cDecoder c) !(dDecoder d) !(eDecoder e) !(fDecoder f) !(gDecoder g) !(hDecoder h))) ||| Decoder that expects a tuple of size 8. export list : ErlDecoder a -> ErlDecoder (List a) list decoder = nil *> pure [] `lazyAlt` map (\(x :: xs) => x :: xs) (cons decoder (assert_total (list decoder))) ||| Decoder that expects an Erlang list, where each element in the list must ||| match the given decoder. export hList : ErlDecoders xs -> ErlDecoder (ErlList xs) hList [] = nil *> pure [] hList (x :: xs) = map (\(y :: ys) => y :: ys) (cons x (hList xs)) ||| Decoder that expects an Erlang charlist. -- http://erlang.org/doc/man/unicode.html -- charlist() = [char()] export charlist : ErlDecoder ErlCharlist charlist = do xs <- list codepoint pure (erlUnsafeCast ErlCharlist xs) ||| Decoder that expects an Erlang IO data -- http://erlang.org/doc/man/unicode.html#type-chardata -- chardata() = charlist() | unicode_binary() -- charlist() = maybe_improper_list(char() | unicode_binary() | charlist(), unicode_binary() | []) -- maybe_improper_list(X, Y) = [X | maybe_improper_list(X, Y)] export ioData : ErlDecoder ErlTerm ioData = map believe_me string `lazyAlt` map believe_me nil `lazyAlt` map believe_me (cons (assert_total listHead) (assert_total ioData)) where listHead : ErlDecoder String listHead = map believe_me codepoint `lazyAlt` -- NOTE: Codepoints are only valid in head position in an IO list map believe_me string `lazyAlt` map believe_me nil `lazyAlt` map believe_me (cons (assert_total listHead) ioData) ||| Decoder for an Erlang map entry. export mapEntry : ErlType key => key -> ErlDecoder value -> ErlDecoder value mapEntry key (MkDecoder valueDecoder) = MkDecoder (\term => do let Just m = prim__erlDecodeAnyMap term | Nothing => Left (Error "Expected a map") let lookupResult = erlUnsafeCall ErlTerm "maps" "find" [key, m] let Just (MkTuple2 ok value) = prim__erlDecodeTuple2 lookupResult | Nothing => Left (Error "Could not find key in map") valueDecoder value) ||| Decoder for an Erlang map containing at least the specified entries. ||| ||| This function does not put any restrictions on the keys and values because ||| getting them wrong just means you won't get the expected result. It will ||| not result in any run-time errors. export mapSubset : ErlMapDecoders xs -> ErlDecoder (ErlMapSubset xs) mapSubset [] = believe_me anyMap mapSubset (MkDecoderMapEntry key valueDecoder :: xs) = believe_me (mapEntry (MkRaw key) valueDecoder *> mapSubset xs) ||| Decoder that expects a function of arity 0. ||| ||| The returned function from the `fun/N` decoders is wrapped in the `IO` ||| type in case the function performs any side-effects. The returned function ||| is also wrapped in a try/catch in case in crashes at run-time. ||| ||| The try/catch is especially important for the `fun/N` decoders where the ||| arity is 1 or higher because, in these cases, the caller is allowed to choose ||| any type for the input parameters of the returned function. If the values ||| passed to the Erlang function are not what the Erlang function expects, it ||| could cause an run-time error. export fun0 : ErlDecoder (IO (Either ErlException ErlTerm)) fun0 = MkDecoder (\term => do let Just (MkIOFun0 fun) = prim__erlDecodeFun0 term | Nothing => Left (Error "Expected a function of arity 0") pure $ erlTryCatch fun) ||| Decoder that expects a function of arity 1. ||| ||| See the documentation of `fun0` for more details. export fun1 : (a : Type) -> ErlDecoder (a -> IO (Either ErlException ErlTerm)) fun1 aType = MkDecoder (\term => do let Just (MkIOFun1 fun) = prim__erlDecodeFun1 term | Nothing => Left (Error "Expected a function of arity 1") pure $ (\a => erlTryCatch (fun a))) ||| Decoder that expects a function of arity 2. ||| ||| See the documentation of `fun0` for more details. export fun2 : (a : Type) -> (b : Type) -> ErlDecoder (a -> b -> IO (Either ErlException ErlTerm)) fun2 aType bType = MkDecoder (\term => do let Just (MkIOFun2 fun) = prim__erlDecodeFun2 term | Nothing => Left (Error "Expected a function of arity 2") pure $ (\a, b => erlTryCatch (fun a b))) ||| Decoder that expects a function of arity 3. ||| ||| See the documentation of `fun0` for more details. export fun3 : (a : Type) -> (b : Type) -> (c : Type) -> ErlDecoder (a -> b -> c -> IO (Either ErlException ErlTerm)) fun3 aType bType cType = MkDecoder (\term => do let Just (MkIOFun3 fun) = prim__erlDecodeFun3 term | Nothing => Left (Error "Expected a function of arity 3") pure $ (\a, b, c => erlTryCatch (fun a b c))) ||| Decoder that expects a function of arity 4. ||| ||| See the documentation of `fun0` for more details. export fun4 : (a : Type) -> (b : Type) -> (c : Type) -> (d : Type) -> ErlDecoder (a -> b -> c -> d -> IO (Either ErlException ErlTerm)) fun4 aType bType cType dType = MkDecoder (\term => do let Just (MkIOFun4 fun) = prim__erlDecodeFun4 term | Nothing => Left (Error "Expected a function of arity 4") pure $ (\a, b, c, d => erlTryCatch (fun a b c d))) ||| Decoder that expects a function of arity 5. ||| ||| See the documentation of `fun0` for more details. export fun5 : (a : Type) -> (b : Type) -> (c : Type) -> (d : Type) -> (e : Type) -> ErlDecoder (a -> b -> c -> d -> e -> IO (Either ErlException ErlTerm)) fun5 aType bType cType dType eType = MkDecoder (\term => do let Just (MkIOFun5 fun) = prim__erlDecodeFun5 term | Nothing => Left (Error "Expected a function of arity 5") pure $ (\a, b, c, d, e => erlTryCatch (fun a b c d e))) ||| Decoder that expects a function of arity 6. ||| ||| See the documentation of `fun0` for more details. export fun6 : (a : Type) -> (b : Type) -> (c : Type) -> (d : Type) -> (e : Type) -> (f : Type) -> ErlDecoder (a -> b -> c -> d -> e -> f -> IO (Either ErlException ErlTerm)) fun6 aType bType cType dType eType fType = MkDecoder (\term => do let Just (MkIOFun6 fun) = prim__erlDecodeFun6 term | Nothing => Left (Error "Expected a function of arity 6") pure $ (\a, b, c, d, e, f => erlTryCatch (fun a b c d e f))) ||| Decoder that expects a function of arity 7. ||| ||| See the documentation of `fun0` for more details. export fun7 : (a : Type) -> (b : Type) -> (c : Type) -> (d : Type) -> (e : Type) -> (f : Type) -> (g : Type) -> ErlDecoder (a -> b -> c -> d -> e -> f -> g -> IO (Either ErlException ErlTerm)) fun7 aType bType cType dType eType fType gType = MkDecoder (\term => do let Just (MkIOFun7 fun) = prim__erlDecodeFun7 term | Nothing => Left (Error "Expected a function of arity 7") pure $ (\a, b, c, d, e, f, g => erlTryCatch (fun a b c d e f g))) ||| Decoder that expects a function of arity 8. ||| ||| See the documentation of `fun0` for more details. export fun8 : (a : Type) -> (b : Type) -> (c : Type) -> (d : Type) -> (e : Type) -> (f : Type) -> (g : Type) -> (h : Type) -> ErlDecoder (a -> b -> c -> d -> e -> f -> g -> h -> IO (Either ErlException ErlTerm)) fun8 aType bType cType dType eType fType gType hType = MkDecoder (\term => do let Just (MkIOFun8 fun) = prim__erlDecodeFun8 term | Nothing => Left (Error "Expected a function of arity 8") pure $ (\a, b, c, d, e, f, g, h => erlTryCatch (fun a b c d e f g h))) ||| Decoder that expects an Erlang boolean value. ||| ||| Note that the Idris `Bool` type is not represented as the Erlang atoms ||| `true` and `false`. It is still useful to be able to decode those atoms ||| into the type `Bool`. export bool : ErlDecoder Bool bool = (exact (MkAtom "true") *> pure True) <|> (exact (MkAtom "false") *> pure False) ||| Decoder that expects an Erlang value in the format `{ok, Value}`. export okTuple : ErlDecoder a -> ErlDecoder a okTuple decoder = map (\(MkTuple2 _ result) => result) (tuple2 (exact (MkAtom "ok")) decoder) ||| Decoder that expects an Erlang value in the format `{error, Value}`. export errorTuple : ErlDecoder a -> ErlDecoder a errorTuple decoder = map (\(MkTuple2 _ result) => result) (tuple2 (exact (MkAtom "error")) decoder)
Load LFindLoad. From lfind Require Import LFind. From QuickChick Require Import QuickChick. From adtind Require Import goal33. Derive Show for natural. Derive Arbitrary for natural. Instance Dec_Eq_natural : Dec_Eq natural. Proof. dec_eq. Qed. Lemma conj5eqsynthconj3 : forall (lv0 : natural), (@eq natural (mult lv0 Zero) (mult Zero Zero)). Admitted. QuickChick conj5eqsynthconj3.
State Before: R : Type u_1 inst✝⁸ : CommRing R M : Submonoid R S : Type u_3 inst✝⁷ : CommRing S inst✝⁶ : Algebra R S P : Type ?u.52206 inst✝⁵ : CommRing P inst✝⁴ : IsLocalization M S R' : Type u_2 inst✝³ : CommRing R' inst✝² : Algebra R R' inst✝¹ : Algebra S R' inst✝ : IsScalarTower R S R' p : S[X] x : R' hx : ↑(aeval x) p = 0 ⊢ ↑(aeval x) (integerNormalization M p) = 0 State After: no goals Tactic: rw [aeval_def, IsScalarTower.algebraMap_eq R S R', integerNormalization_eval₂_eq_zero _ _ _ hx]
module Incrementer import public Numeric %default total ||| Increment integer public export incrementer : Integer -> Integer incrementer = (+1)
Require Import Reals Psatz Omega Fourier. From stdpp Require Import tactics list. From discprob.basic Require Import seq_ext. From mathcomp Require Import bigop. From discprob.measure Require Export measures borel convergence integral_prelim. Require Import ClassicalEpsilon SetoidList. Section integral. Context {A: Type}. Context {F: measurable_space A}. Context (μ: measure A). Local Notation is_pos_integral := (@is_pos_integral A F μ). Local Notation ex_pos_integral := (@ex_pos_integral A F μ). Local Notation Pos_integral := (@Pos_integral A F μ). Definition is_integral (f: A → R) v := measurable f ∧ ∃ v1 v2, is_pos_integral (λ x, Rmax (f x) 0) v1 ∧ is_pos_integral (λ x, Rmax (- f x) 0) v2 ∧ v = v1 - v2. Definition ex_integral (f: A → R) := ∃ v, is_integral f v. Definition Integral (f : A → R) : R := Pos_integral (λ x, Rmax (f x) 0) - Pos_integral (λ x, Rmax (- f x) 0). Definition is_integral_over (U : A → Prop) (f: A → R) v := F U ∧ is_integral (λ x, f x * match excluded_middle_informative (U x) with | left _ => 1 | right _ => 0 end) v. Definition ex_integral_over U f := ∃ v, is_integral_over U f v. Definition Integral_over U f := Integral (λ x, f x * match excluded_middle_informative (U x) with | left _ => 1 | right _ => 0 end). Lemma is_integral_unique f v : is_integral f v → Integral f = v. Proof. rewrite /is_integral. intros (Hmeas&v1&v2&?&?&Heq). rewrite /Integral. erewrite is_pos_integral_unique; eauto. erewrite is_pos_integral_unique; eauto. Qed. Lemma Integral_correct f: ex_integral f → is_integral f (Integral f). Proof. intros [v Hpos]. rewrite (is_integral_unique f v) //=. Qed. Lemma is_pos_integral_diff f1 f2 g1 g2 v1 v2 v1' v2': (∀ x, 0 <= f1 x) → (∀ x, 0 <= f2 x) → (∀ x, 0 <= g1 x) → (∀ x, 0 <= g2 x) → (∀ x, f1 x - f2 x = g1 x - g2 x) → is_pos_integral f1 v1 → is_pos_integral f2 v2 → is_pos_integral g1 v1' → is_pos_integral g2 v2' → v1 - v2 = v1' - v2'. Proof. intros ???? Hdiff Hi1 Hi2 Hi1' Hi2'. assert (Hsum: ∀ x, f1 x + g2 x = g1 x + f2 x). { intros x. specialize (Hdiff x). nra. } cut (v1 + v2' = v1' + v2); first by nra. feed pose proof (is_pos_integral_plus μ f1 v1 g2 v2'); eauto. feed pose proof (is_pos_integral_plus μ g1 v1' f2 v2); eauto. etransitivity; last apply is_pos_integral_unique; eauto. symmetry. apply is_pos_integral_unique. setoid_rewrite <-Hsum. done. Qed. Lemma is_integral_scal k f v: is_integral f v → is_integral (λ x, k * f x) (k * v). Proof. destruct (Rle_dec 0 k). - intros (Hmeas&v1&v2&Hpos1&Hpos2&Hdiff). split. { by apply measurable_scal. } exists (k * v1), (k * v2). split_and!. * eapply is_pos_integral_ext; last first. { eapply is_pos_integral_scal; auto; last eauto. intros x => //=. apply Rmax_r. } intros x => //=. replace 0 with (k * 0) at 2 by field. rewrite Rmult_comm Rmax_mult; auto. f_equal; nra. * eapply is_pos_integral_ext; last first. { eapply is_pos_integral_scal; auto; last apply Hpos2. intros x => //=. apply Rmax_r. } intros x => //=. replace 0 with (k * 0) at 2 by field. rewrite Rmult_comm Rmax_mult; auto. f_equal; nra. * nra. - intros (Hmeas&v1&v2&Hpos1&Hpos2&Hdiff). split. { by apply measurable_scal. } exists (-k * v2), (-k * v1). split_and!. * eapply is_pos_integral_ext; last first. { eapply is_pos_integral_scal; auto; last eauto; try nra. intros x => //=. apply Rmax_r. } intros x => //=. replace 0 with (- k * 0) at 2 by field. rewrite Rmult_comm Rmax_mult; auto; last nra. f_equal; nra. * eapply is_pos_integral_ext; last first. { eapply is_pos_integral_scal; auto; last eauto; try nra. intros x => //=. apply Rmax_r. } intros x => //=. replace 0 with (- k * 0) at 2 by field. rewrite Rmult_comm Rmax_mult; auto; last nra. f_equal; nra. * nra. Qed. Lemma ex_integral_scal k f: ex_integral f → ex_integral (λ x, k * f x). Proof. intros (v1&?); eexists; eapply is_integral_scal; eauto. Qed. Lemma Integral_scal k f: ex_integral f → Integral (λ x, k * f x) = k * Integral f. Proof. intros Hex. apply is_integral_unique. apply is_integral_scal; apply Integral_correct; eauto. Qed. Lemma is_integral_plus f1 v1 f2 v2: is_integral f1 v1 → is_integral f2 v2 → is_integral (λ x, f1 x + f2 x) (v1 + v2). Proof. intros Hi1 Hi2. destruct Hi1 as (Hmeas1&v1p&v1n&Hi1p&Hi1n&Hdiff1). destruct Hi2 as (Hmeas2&v2p&v2n&Hi2p&Hi2n&Hdiff2). split. - apply measurable_plus; auto. - exists (Pos_integral (λ x, (Rmax (f1 x + f2 x) 0))). exists (Pos_integral (λ x, (Rmax (-(f1 x + f2 x)) 0))). assert (ex_pos_integral (λ x, (Rmax (f1 x + f2 x) 0))). { edestruct (is_pos_integral_mono_ex μ (λ x, Rmax (f1 x + f2 x) 0) (λ x, Rmax (f1 x) 0 + Rmax (f2 x) 0)) as (Hex&?); eauto. ** intros x => //=. apply Rmax_r. ** intros x => //=. repeat apply Rmax_case_strong; nra. ** apply measurable_Rmax. *** apply measurable_plus; auto. *** eapply measurable_const. ** apply is_pos_integral_plus; eauto using Rmax_r. } assert (ex_pos_integral (λ x, (Rmax (- (f1 x + f2 x)) 0))). { edestruct (is_pos_integral_mono_ex μ (λ x, Rmax (- (f1 x + f2 x)) 0) (λ x, Rmax (- f1 x) 0 + Rmax (- f2 x) 0)) as (Hex&?); eauto. ** intros x => //=. apply Rmax_r. ** intros x => //=. repeat apply Rmax_case_strong; nra. ** apply measurable_Rmax. *** eapply measurable_opp. apply measurable_plus; auto. *** eapply measurable_const. ** apply is_pos_integral_plus; eauto using Rmax_r. } split_and!. * apply Pos_integral_correct; eauto. * apply Pos_integral_correct; eauto. * replace (v1 + v2) with ((v1p + v2p) - (v1n + v2n)) by nra. eapply (is_pos_integral_diff (λ x, Rmax (f1 x) 0 + Rmax (f2 x) 0) (λ x, Rmax (- f1 x) 0 + Rmax (- f2 x) 0)); try (eapply Pos_integral_correct; eauto); try (intros x; eapply Rmax_r; eauto). ** intros; repeat apply Rmax_case_strong; nra. ** intros; repeat apply Rmax_case_strong; nra. ** intros; repeat apply Rmax_case_strong; nra. ** apply is_pos_integral_plus; auto using Rmax_r. ** apply is_pos_integral_plus; auto using Rmax_r. Qed. Lemma ex_integral_plus f1 f2: ex_integral f1 → ex_integral f2 → ex_integral (λ x, f1 x + f2 x). Proof. intros (v1&?) (v2&?). eexists; eauto using is_integral_plus. Qed. Lemma Integral_plus f1 f2: ex_integral f1 → ex_integral f2 → Integral (λ x, f1 x + f2 x) = Integral f1 + Integral f2. Proof. intros Hex1 Hex2. apply is_integral_unique. apply is_integral_plus; apply Integral_correct; eauto. Qed. Lemma is_integral_ext f1 f2 v: (∀ x, f1 x = f2 x) → is_integral f1 v → is_integral f2 v. Proof. intros Heq (Hmeas&Hp). split. - eapply measurable_proper. * intros x. rewrite -Heq. reflexivity. * eauto. - destruct Hp as (v1&v2&?&?&?). exists v1, v2; split_and!; eauto. * setoid_rewrite <-Heq. auto. * setoid_rewrite <-Heq. auto. Qed. Lemma ex_integral_ext f1 f2: (∀ x, f1 x = f2 x) → ex_integral f1 → ex_integral f2. Proof. intros Hex (v1&?). exists v1. eapply is_integral_ext; eauto. Qed. Lemma Integral_ext f1 f2: (∀ x, f1 x = f2 x) → Integral f1 = Integral f2. Proof. intros Hex. rewrite /Integral. f_equal; apply Pos_integral_ext => x; rewrite Hex; done. Qed. Global Instance is_integral_Proper: Proper (pointwise_relation _ eq ==> eq ==> iff) (is_integral). Proof. intros ?? Heq ?? ->. split; eapply is_integral_ext; eauto. Qed. Global Instance ex_integral_Proper: Proper (pointwise_relation _ eq ==> iff) (ex_integral). Proof. intros ?? Heq. split; eapply ex_integral_ext; eauto. Qed. Global Instance Integral_Proper: Proper (pointwise_relation _ eq ==> eq) Integral. Proof. intros ?? Heq. by apply Integral_ext. Qed. Lemma is_integral_minus f1 v1 f2 v2: is_integral f1 v1 → is_integral f2 v2 → is_integral (λ x, f2 x - f1 x) (v2 - v1). Proof. intros Hi1 Hi2. assert (Heq: ∀ x, f2 x - f1 x = f2 x + -1 * f1 x) by (intros; nra). replace (v2 - v1) with (v2 + - 1 * v1) by field. setoid_rewrite Heq. apply is_integral_plus; auto. apply is_integral_scal. done. Qed. Lemma ex_integral_minus f1 f2: ex_integral f1 → ex_integral f2 → ex_integral (λ x, f2 x - f1 x). Proof. intros (v1&?) (v2&?); eexists; eapply is_integral_minus; eauto. Qed. Lemma Integral_minus f1 f2: ex_integral f1 → ex_integral f2 → Integral (λ x, f1 x - f2 x) = Integral f1 - Integral f2. Proof. intros Hex1 Hex2. apply is_integral_unique. apply is_integral_minus; apply Integral_correct; eauto. Qed. Lemma is_pos_integral_0: is_pos_integral (λ _, 0) 0. Proof. split. - apply measurable_const. - split. * intros ? (wpt&?&?). subst. replace 0 with (wpt_integral μ (wpt_const 0)). { apply wpt_integral_mono => //=. intros. rewrite wpt_const_spec. done. } rewrite wpt_integral_const; nra. * intros ? H. apply H. exists (wpt_const 0); split. ** intros; rewrite wpt_const_spec; nra. ** rewrite wpt_integral_const; nra. Qed. Lemma Pos_integral_0: Pos_integral (λ _, 0) = 0. Proof. apply is_pos_integral_unique, is_pos_integral_0. Qed. Hint Resolve is_pos_integral_measurable. Lemma is_integral_equiv_pos_integral f v: (∀ x, 0 <= f x) → is_integral f v ↔ is_pos_integral f v. Proof. intros Hpos; split. - intros (Hmeas&v1&v2&?&Hp2&?). cut (v2 = 0). { intros. replace v with v1 by nra. eapply is_pos_integral_ext; try eassumption. intros => //=. rewrite Rmax_left; eauto. } assert (Heq: ∀ x, Rmax (- f x) 0 = 0). { intros. rewrite Rmax_right; auto. apply Rge_le, Ropp_0_le_ge_contravar. eauto. } setoid_rewrite Heq in Hp2. erewrite <-(is_pos_integral_unique μ _ v2); eauto. apply is_pos_integral_unique. apply is_pos_integral_0. - intros Hpos'. split; eauto. * exists v, 0; split_and!; last field. ** eapply is_pos_integral_ext; last eassumption. intros x. rewrite Rmax_left; eauto. ** eapply is_pos_integral_ext; last eapply is_pos_integral_0. intros x. rewrite Rmax_right; eauto. apply Rge_le, Ropp_0_le_ge_contravar. eauto. Qed. Lemma ex_integral_equiv_pos_integral f: (∀ x, 0 <= f x) → ex_integral f ↔ ex_pos_integral f. Proof. intros Hpos. split; intros (v&?); eexists; eapply is_integral_equiv_pos_integral; eauto. Qed. Lemma Integral_equiv_Pos_integral f: (∀ x, 0 <= f x) → Integral f = Pos_integral f. Proof. intros Hpos. rewrite /Integral. assert (Hequiv: ∀ x, (λ x, Rmax (- f x) 0) x = 0). { intros x. specialize (Hpos x). apply Rmax_case_strong; nra. } setoid_rewrite Hequiv. rewrite Pos_integral_0 Rminus_0_r. apply Pos_integral_ext. intros x. rewrite Rmax_left; auto. Qed. Lemma is_integral_mono f1 v1 f2 v2: (∀ x, f1 x <= f2 x) → is_integral f1 v1 → is_integral f2 v2 → v1 <= v2. Proof. intros Hle Hint1 Hint2. cut (0 <= v2 - v1); first by nra. assert (His: is_integral (λ x, f2 x - f1 x) (v2 - v1)). { apply is_integral_minus; auto. } apply is_integral_equiv_pos_integral in His; last by (intros x; specialize (Hle x); nra). eapply is_pos_integral_mono in His; first eassumption; try eapply is_pos_integral_0. intros x => //=. specialize (Hle x); nra. Qed. Lemma Integral_mono f1 f2: (∀ x, f1 x <= f2 x) → ex_integral f1 → ex_integral f2 → Integral f1 <= Integral f2. Proof. intros Hmono (v1&Heq1) (v2&Heq2). rewrite (is_integral_unique _ _ Heq1). rewrite (is_integral_unique _ _ Heq2). eapply is_integral_mono; eauto. Qed. Lemma is_integral_measurable f v: is_integral f v → measurable f. Proof. destruct 1; eauto. Qed. Lemma ex_integral_measurable f: ex_integral f → measurable f. Proof. destruct 1 as (?&?); eauto using is_integral_measurable. Qed. Hint Resolve is_integral_measurable ex_integral_measurable. Lemma is_pos_integral_wpt wpt: (∀ x, 0 <= wpt_fun wpt x) → is_pos_integral (wpt_fun wpt) (wpt_integral μ wpt). Proof. intros Hpos. eapply (is_pos_integral_mct_wpt μ (λ n, wpt)). - apply wpt_fun_measurable. - intros; apply is_lim_seq_const. - intros; reflexivity. - apply is_lim_seq_const. Qed. Lemma is_integral_wpt wpt: is_integral (wpt_fun wpt) (wpt_integral μ wpt). Proof. induction wpt using wpt_induction. - eapply is_integral_ext; eauto. rewrite (wpt_integral_proper _ wpt2 wpt1); auto. by symmetry. - apply is_integral_equiv_pos_integral. { intros x. rewrite wpt_indicator_spec; destruct excluded_middle_informative => //=; nra. } apply is_pos_integral_wpt. { intros x. rewrite wpt_indicator_spec; destruct excluded_middle_informative => //=; nra. } - rewrite wpt_integral_plus. eapply is_integral_ext. { intros x; by rewrite wpt_plus_spec. } apply is_integral_plus; eauto. - rewrite wpt_integral_scal. eapply is_integral_ext. { intros x; by rewrite wpt_scal_spec. } apply is_integral_scal; eauto. Qed. Lemma ex_integral_wpt wpt: ex_integral (wpt_fun wpt). Proof. eexists. eapply is_integral_wpt. Qed. Lemma Integral_wpt wpt: Integral (wpt_fun wpt) = wpt_integral μ wpt. Proof. apply is_integral_unique, is_integral_wpt. Qed. Lemma is_integral_0: is_integral (λ _, 0) 0. Proof. apply is_integral_equiv_pos_integral; first reflexivity. apply is_pos_integral_0. Qed. Lemma Integral_0: Integral (λ _, 0) = 0. Proof. apply is_integral_unique, is_integral_0. Qed. Lemma ex_integral_sum_n fn m: (∀ n, (n <= m)%nat → ex_integral (fn n)) → ex_integral (λ x, sum_n (λ n, fn n x) m). Proof. induction m. - intros Hex. setoid_rewrite sum_O. eauto. - intros Hex. setoid_rewrite sum_Sn. apply ex_integral_plus; auto. Qed. Lemma Integral_sum_n fn m: (∀ n, (n <= m)%nat → ex_integral (fn n)) → Integral (λ x, sum_n (λ n, fn n x) m) = sum_n (λ n, Integral (fn n)) m. Proof. induction m. - intros Hex. setoid_rewrite sum_O. done. - intros Hex. setoid_rewrite sum_Sn. rewrite /plus//=. rewrite Integral_plus; eauto using ex_integral_sum_n. f_equal; eauto. Qed. Lemma is_integral_ge0 f v: (∀ x, 0 <= f x) → is_integral f v → v >= 0. Proof. intros Hpos His. apply Rle_ge. eapply is_integral_mono. - eapply Hpos. - apply is_integral_0. - eauto. Qed. Lemma Pos_integral_ge0 f: (∀ x, 0 <= f x) → Pos_integral f >= 0. Proof. intros Hpos. rewrite /Pos_integral. destruct excluded_middle_informative; last nra. destruct excluded_middle_informative; last nra. apply Rle_ge. eapply (Rle_trans _ (wpt_integral μ (wpt_indicator empty_set (sigma_empty_set F)))). { rewrite wpt_integral_indicator measure_empty. nra. } destruct (completeness _) as (?&Hlub). apply Hlub. eexists. split; eauto. intros x'. rewrite wpt_indicator_spec. destruct (excluded_middle_informative) as [[]|]; auto. Qed. Lemma Integral_ge0 f: (∀ x, 0 <= f x) → Integral f >= 0. Proof. intros Hpos. rewrite /Integral. cut (Pos_integral (λ x, Rmax (- f x) 0) = 0). { intros ->. feed pose proof (Pos_integral_ge0 (λ x, Rmax (f x) 0)). { intros. apply Rmax_case_strong; nra. } nra. } rewrite -{2}Pos_integral_0. apply Pos_integral_ext. intros. specialize (Hpos x). apply Rmax_case_strong => //=; nra. Qed. Hint Resolve is_integral_wpt ex_integral_wpt. Lemma ex_integral_mono_ex f1 f2: (∀ x, Rabs (f1 x) <= f2 x) → measurable f1 → ex_integral f2 → ex_integral f1. Proof. intros Hb Hmeas (v&(?&?&?&?&?&?)). edestruct (is_pos_integral_mono_ex μ (λ x, Rmax (f1 x) 0) (λ x, Rmax (f2 x) 0)) as ((xp&?)&?). { intros ?; apply Rmax_case_strong; nra. } { intros x' => //=. specialize (Hb x'). move: Hb. apply Rabs_case; do 2 apply Rmax_case_strong; nra. } { apply measurable_Rmax; eauto. measurable. } { eauto. } edestruct (is_pos_integral_mono_ex μ (λ x, Rmax (- f1 x) 0) (λ x, Rmax (f2 x) 0)) as ((xn&?)&?). { intros ?; apply Rmax_case_strong; nra. } { intros x' => //=. generalize (Hb x'). apply Rabs_case; do 2 apply Rmax_case_strong; nra. } { apply measurable_Rmax; eauto; measurable. } { eauto. } exists (xp - xn). split; auto. exists xp, xn. eauto. Qed. Lemma ex_integral_Rabs f: measurable f → ex_integral f ↔ ex_integral (λ x, Rabs (f x)). Proof. intros Hmeas. split. - intros (v&Hmeas'&(v1&v2&His1&His2&Heq)). assert (∀ x, Rabs (f x) = Rmax (f x) 0 + Rmax (- f x) 0) as Hequiv. { intros; apply Rabs_case; do 2 apply Rmax_case_strong; nra. } setoid_rewrite Hequiv. apply ex_integral_plus. * apply ex_integral_equiv_pos_integral; last by eexists; eauto. intros. apply Rmax_case_strong; nra. * apply ex_integral_equiv_pos_integral; last by eexists; eauto. intros. apply Rmax_case_strong; nra. - intros. eapply ex_integral_mono_ex; eauto. intros x. rewrite //=. reflexivity. Qed. Lemma Integral_mono_pos f1 f2: (∀ x, 0 <= f1 x) → (∀ x, f1 x <= f2 x) → measurable f1 → ex_integral f2 → Integral f1 <= Integral f2. Proof. intros Hpos Hmono Hmeas Hex. eapply Integral_mono; eauto. eapply ex_integral_mono_ex. eauto. { intros. rewrite Rabs_right; eauto. } { auto. } { auto. } Qed. Lemma is_integral_wpt_ae_0 wpt: (∀ x, 0 <= wpt_fun wpt x) → almost_everywhere_meas μ (λ x, wpt_fun wpt x = 0) → is_integral (wpt_fun wpt) 0. Proof. intros Hpos. eapply (wpt_pos_induction (λ wpt, almost_everywhere_meas μ (λ x : A, wpt_fun wpt x = 0) → is_integral (wpt_fun wpt) 0)). - intros wpt1 wpt2 Heq IH Hae. eapply is_integral_ext; last eapply IH; eauto. eapply almost_everywhere_meas_ext; eauto. intros ?. by rewrite Heq. - intros U Hmeas Hae. cut (Integral (wpt_fun (wpt_indicator U Hmeas)) = 0). { intros <-. apply Integral_correct; auto. } rewrite Integral_wpt wpt_integral_indicator. destruct Hae as (?&His0). apply Rle_antisym; last by apply Rge_le, measure_nonneg. rewrite -His0. apply measure_mono; auto. intros x HU Hneg. rewrite wpt_indicator_spec in Hneg. destruct (excluded_middle_informative); try contradiction. simpl in Hneg; nra. - intros wpt1 wpt2 Hpos1 IH1 Hpos2 IH2 Hae. replace 0 with (0 + 0) by nra. eapply is_integral_ext. { intros x; by rewrite wpt_plus_spec. } apply is_integral_plus. * eapply IH1. eapply almost_everywhere_meas_mono; eauto. { apply measurable_fun_eq_0; auto. } intros x. rewrite wpt_plus_spec. specialize (Hpos1 x). specialize (Hpos2 x). nra. * eapply IH2. eapply almost_everywhere_meas_mono; eauto. { apply measurable_fun_eq_0; auto. } intros x. rewrite wpt_plus_spec. specialize (Hpos1 x). specialize (Hpos2 x). nra. - intros k wpt1 Hkpos Hpos1 IH1 Hae. replace 0 with (k * 0) by field. eapply is_integral_ext. { intros x. rewrite wpt_scal_spec. done. } destruct Hkpos; last first. { subst. setoid_rewrite Rmult_0_l. apply is_integral_0. } apply is_integral_scal. eapply IH1. eapply almost_everywhere_meas_mono; eauto. { apply measurable_fun_eq_0; auto. } intros x. rewrite wpt_scal_spec. nra. - auto. Qed. Lemma is_integral_pos_ae_0 f: measurable f → (∀ x, 0 <= f x) → almost_everywhere_meas μ (λ x, f x = 0) → is_integral f 0. Proof. intros Hmeas Hpos. edestruct (wpt_approx_measurable _ Hpos Hmeas) as (wptn&?&?&Hle&Hposn). intros Hae. apply is_integral_equiv_pos_integral; eauto. eapply is_pos_integral_mct_wpt; eauto. eapply is_lim_seq_ext; last eapply is_lim_seq_const. intros n => //=. rewrite -Integral_wpt. symmetry. apply is_integral_unique. apply is_integral_wpt_ae_0; eauto. eapply almost_everywhere_meas_mono; eauto. { apply measurable_fun_eq_0; auto. } intros x Heq0. specialize (Hle n x). specialize (Hposn n x). nra. Qed. Lemma is_integral_alt (f: A → R) v : (measurable f ∧ ∃ v1 v2, is_integral (λ x, Rmax (f x) 0) v1 ∧ is_integral (λ x, Rmax (- f x) 0) v2 ∧ v = v1 - v2) ↔ is_integral f v. Proof. split. - intros (?&v1&v2&?&?&?). split; auto. exists v1, v2. split_and!; auto; apply is_integral_equiv_pos_integral; eauto; intros x; apply Rmax_case_strong; nra. - intros (Hmeas&(v1&v2&?&?&?)). split; auto. exists v1, v2; split_and!; auto. * apply is_integral_equiv_pos_integral; auto using Rmax_r. * apply is_integral_equiv_pos_integral; auto using Rmax_r. Qed. Lemma ex_integral_alt (f: A → R) : (measurable f ∧ ex_integral (λ x, Rmax (f x) 0) ∧ ex_integral (λ x, Rmax (- f x) 0)) ↔ ex_integral f. Proof. split. - intros (Hmeas&Hex1&Hex2). destruct Hex1 as (v1&His1). destruct Hex2 as (v2&His2). exists (v1 - v2). apply is_integral_alt. split; auto. exists v1, v2; split_and!; eauto. - intros (Hmeas&His). apply is_integral_alt in His as (?&?&?&?&?&?). split; auto. split; eexists; eauto. Qed. Lemma Integral_alt f: Integral f = Integral (λ x, Rmax (f x) 0) - Integral (λ x, Rmax (- f x) 0). Proof. rewrite {1}/Integral; f_equal; symmetry; apply Integral_equiv_Pos_integral; auto using Rmax_r. Qed. Lemma is_integral_ae_0 f: measurable f → almost_everywhere_meas μ (λ x, f x = 0) → is_integral f 0. Proof. intros Hmeas Hae. apply is_integral_alt; split; auto. exists 0, 0; split_and!; last field. - apply is_integral_pos_ae_0. * apply measurable_Rmax; measurable. * intros; apply Rmax_case_strong; nra. * eapply almost_everywhere_meas_mono; eauto. ** apply measurable_fun_eq_0; auto. apply measurable_Rmax; measurable. ** intros x ->. apply Rmax_case_strong; auto. - apply is_integral_pos_ae_0. * apply measurable_Rmax; measurable. * intros; apply Rmax_case_strong; nra. * eapply almost_everywhere_meas_mono; eauto. ** apply measurable_fun_eq_0; auto. apply measurable_Rmax; measurable. ** intros x ->. apply Rmax_case_strong; auto. nra. Qed. Lemma is_integral_ae_ext f1 f2 v: almost_everywhere_meas μ (λ x, f1 x = f2 x) → measurable f2 → is_integral f1 v → is_integral f2 v. Proof. intros Hae Hmeas His. feed pose proof (is_integral_ae_0 (λ x, f2 x - f1 x)) as Hisdiff. { measurable. eauto. } { eapply almost_everywhere_meas_ext; eauto. split; intros; nra. } specialize (is_integral_plus _ _ _ _ His Hisdiff). rewrite Rplus_0_r. apply is_integral_ext. intros; field. Qed. Lemma ex_integral_ae_ext f1 f2: almost_everywhere_meas μ (λ x, f1 x = f2 x) → measurable f2 → ex_integral f1 → ex_integral f2. Proof. intros Hae Hmeas (v&His). exists v. eapply is_integral_ae_ext; eauto. Qed. Lemma Integral_ae_ext_weak f1 f2: almost_everywhere_meas μ (λ x, f1 x = f2 x) → measurable f2 → ex_integral f1 → Integral f1 = Integral f2. Proof. intros Hae ? Hex. symmetry. apply is_integral_unique. eapply is_integral_ae_ext; eauto. by apply Integral_correct. Qed. Lemma is_integral_levi_pos_ex fn f: measurable f → (∀ x, is_lim_seq (λ n, fn n x) (f x : R)) → (∀ x, ∀ n, 0 <= fn n x) → (∀ x, ∀ n, fn n x <= fn (S n) x) → (∀ n, ex_integral (fn n)) → bound (λ r, ∃ n, is_integral (fn n) r) → ex_integral f ∧ is_lim_seq (λ n, Integral (fn n)) (Integral f). Proof. intros Hmeas Hlim Hpos Hmono Hint_fn Hbounded_int. assert (Hfpos: ∀ x, 0 <= f x). { intros x. eapply is_lim_seq_pos; eauto. intros n. apply Rle_ge; eauto. } assert (Hfn_bounded_fpos: ∀ n x, fn n x <= f x). { intros n x. apply: (is_lim_seq_incr_compare (λ n, fn n x) (f x)); eauto. } assert (Hfn_meas: ∀ n, measurable (fn n)). { intros n. auto. } set (gnk_wit := λ n, constructive_indefinite_description _ (wpt_approx_measurable (fn n) (λ x, Hpos x n) (Hfn_meas n))). set (gnk := λ n, sval (gnk_wit n)). set (hnk := λ n k, nat_rect (λ _, weighted_partition) (wpt_const 0) (λ m w, wpt_max w (gnk m n)) (S k)). set (hn := λ n, hnk n n). assert (Hhnk_mono1: ∀ n k, ∀ x, wpt_fun (hnk n k) x <= wpt_fun (hnk (S n) k) x). { intros n k x. revert n. rewrite /hnk. generalize (wpt_const 0). generalize (S k); clear k. intros k. induction k => //= w n. - reflexivity. - rewrite ?wpt_max_spec. apply Rmax_le_compat. * eapply IHk. * rewrite /gnk/gnk_wit. destruct constructive_indefinite_description as (?&?&?&?); eauto. } assert (Hhnk_mono2: ∀ n k, ∀ x, wpt_fun (hnk n k) x <= wpt_fun (hnk n (S k)) x). { intros n k x. revert n. rewrite /hnk. generalize (wpt_const 0). generalize (S k); clear k. intros k. induction k => //= w n. - rewrite wpt_max_spec. apply Rmax_l. - rewrite ?wpt_max_spec. apply Rmax_l. } assert (Hhnk_mono: ∀ n k, (∀ n' k', (n' <= n)%nat → (k' <= k)%nat → ∀ x, wpt_fun (hnk n' k') x <= wpt_fun (hnk n k) x)). { intros n k n' k' Hle1 Hle2. revert k' k Hle2. induction Hle1. * intros. induction Hle2. ** reflexivity. ** etransitivity; first eauto. eapply Hhnk_mono2. * intros. etransitivity; first eapply IHHle1; eauto. } assert (Hhnk_gnk: ∀ n k, ∀ x, wpt_fun (gnk k n) x <= wpt_fun (hnk n k) x). { intros. rewrite wpt_max_spec. apply Rmax_r. } assert (Hhnk_ub: ∀ n k, (∀ n' k', (n' <= n)%nat → (k' <= k)%nat → ∀ x, wpt_fun (gnk k' n') x <= wpt_fun (hnk n k) x)). { intros ???? Hle1 Hle2 x. etransitivity; first eapply Hhnk_gnk. apply Hhnk_mono; eauto. } assert (Hgnk_bounded_fn: ∀ n k, ∀ x, wpt_fun (gnk n k) x <= fn n x). { rewrite /gnk/gnk_wit => n k x. destruct constructive_indefinite_description as (?&?&?&Hbn&?) => //=. } assert (Hgnk_bounded_f: ∀ n k, ∀ x, wpt_fun (gnk n k) x <= f x). { intros. transitivity (fn n x); eauto. } assert (Hhnk_bounded_fn: ∀ n k, ∀ x, wpt_fun (hnk n k) x <= fn k x). { intros n k x. rewrite /hnk. assert (Hle: ∀ k, wpt_fun (wpt_const 0) x <= fn k x). { rewrite wpt_const_spec. eauto. } rewrite //=. rewrite wpt_max_spec. apply Rmax_lub; last by eauto. revert Hle. generalize (wpt_const 0). induction k => //=. - intros w Hle. rewrite wpt_max_spec. apply Rmax_lub; eauto. etransitivity; first eapply IHk; eauto. transitivity (fn k x); eauto. } assert (Hhnk_bounded_f: ∀ n k, ∀ x, wpt_fun (hnk n k) x <= f x). { intros. transitivity (fn k x); eauto. } assert (∀ n x, 0 <= wpt_fun (hn n) x ). { rewrite /hn. etransitivity; last eapply Hhnk_gnk. rewrite /gnk. destruct (gnk_wit) as (?&?&?&?&?); eauto. } edestruct (is_pos_integral_mct_wpt_ex μ hn f). { auto. } { intros x P => //= Hloc. destruct Hloc as (eps&Heps). edestruct (Hlim x (ball (f x) (pos_div_2 eps))) as (n1&Hn1). { rewrite //=. apply (locally_ball _ (pos_div_2 eps)). } destruct (proj2_sig (gnk_wit n1)) as (Hlb&Hlim_gnk&Hbounded_gnk&?). destruct (Hlim_gnk x (ball (fn n1 x) (pos_div_2 (pos_div_2 eps)))) as (n2&Hn2). { rewrite //=. apply (locally_ball _ (pos_div_2 (pos_div_2 eps))). } exists (max n1 n2). intros n Hge. apply Heps. rewrite /ball//=/AbsRing_ball/abs/minus/plus/opp//=. rewrite Rabs_left1; last first. { rewrite /hn. specialize (Hhnk_bounded_f n n x); eauto. nra. } feed pose proof (Hn1 n1) as Hn1'. { etransitivity; last eauto. reflexivity. } rewrite /ball//=/AbsRing_ball/abs/minus/plus/opp//= in Hn1'. rewrite Rabs_left1 in Hn1'; last first. { specialize (Hfn_bounded_fpos n1 x). nra. } feed pose proof (Hn2 n) as Hn2'. { etransitivity; last eauto. apply Nat.le_max_r. } rewrite /ball//=/AbsRing_ball/abs/minus/plus/opp//= in Hn2'. rewrite Rabs_left1 in Hn2'; last first. { specialize (Hbounded_gnk n x). nra. } specialize (Hbounded_gnk n x). specialize (Hgnk_bounded_f n n x). rewrite /gnk in Hgnk_bounded_f. specialize (Hhnk_bounded_f n n x). feed pose proof (Hhnk_ub n n n n1) as Hhn_ub. { reflexivity. } { etransitivity; last eauto. apply Nat.le_max_l. } specialize (Hhn_ub x). rewrite /hn. rewrite /gnk in Hhn_ub. destruct eps as (eps&hgt0) => //=. rewrite //= in Hn1' Hn2'. nra. } { eauto. } { destruct Hbounded_int as (v&Hspec). exists v. intros r (n&<-). transitivity (Integral (fn n)); first eapply (is_integral_mono (λ x, wpt_fun (hn n) x) _ (fn n)); last eauto. - intros x. rewrite /hn. eauto. - eapply is_integral_equiv_pos_integral; eauto. eapply is_pos_integral_wpt; eauto. - apply Integral_correct; eauto. - eapply Hspec. exists n; eauto using Integral_correct. } split. * apply ex_integral_equiv_pos_integral; eauto. * rewrite Integral_equiv_Pos_integral; eauto. apply (is_lim_seq_le_le (λ n, wpt_integral μ (hn n)) _ (λ n, Pos_integral f)); first split; eauto. { eapply (is_integral_mono (wpt_fun (hn n)) _ (fn n) _). * eauto. * apply is_integral_equiv_pos_integral; eauto. eapply is_pos_integral_wpt; eauto. * apply Integral_correct. eauto. } rewrite Integral_equiv_Pos_integral; eauto. eapply (is_pos_integral_mono μ (fn n) f); eauto. ** apply Pos_integral_correct. apply ex_integral_equiv_pos_integral; eauto. ** by apply Pos_integral_correct. ** apply is_lim_seq_const. Qed. Lemma is_integral_levi_ex fn f: measurable f → (∀ x, is_lim_seq (λ n, fn n x) (f x : R)) → (∀ x, ∀ n, fn n x <= fn (S n) x) → (∀ n, ex_integral (fn n)) → bound (λ r, ∃ n, is_integral (fn n) r) → ex_integral f ∧ is_lim_seq (λ n, Integral (fn n)) (Integral f). Proof. intros Hmeas Hlim Hmono Hex Hbounded_int. set (fn' := λ n x, fn n x - fn O x). set (f' := λ x, f x - fn O x). assert (∀ n : nat, ex_integral (fn' n)). { intros n. rewrite /fn'. apply ex_integral_minus; eauto. } edestruct (is_integral_levi_pos_ex fn' f'). - rewrite /f'. apply measurable_minus; eauto. - rewrite /fn'/f' => x. eapply is_lim_seq_minus; eauto. * apply is_lim_seq_const. * rewrite //=. - intros x n. rewrite /fn'. cut (fn O x <= fn n x); first nra. clear -Hmono; induction n. * nra. * etransitivity; eauto. - rewrite /fn'; intros; apply Rplus_le_compat; eauto. reflexivity. - intros n. rewrite /fn'. apply ex_integral_minus; eauto. - destruct Hbounded_int as (v&Hbound). exists (v - Integral (fn O)). intros r (n&His). rewrite /fn' in His. assert (r = Integral (λ x, fn n x - fn O x)) as ->. { symmetry. apply is_integral_unique; eauto. } rewrite Integral_minus; eauto. cut (Integral (fn n) <= v); first by nra. eapply Hbound. exists n. apply Integral_correct; eauto. - assert (Hext: ∀ x : A, f' x + fn O x = f x). { rewrite /f' => x. nra. } assert (Hextn: ∀ n x, fn' n x + fn O x = fn n x). { rewrite /fn' => n x. nra. } assert (ex_integral f). { eapply (ex_integral_ext (λ x, f' x + fn O x)); eauto. apply ex_integral_plus; eauto. } split; auto. * eapply is_lim_seq_ext. { intros n. apply Integral_ext; first eapply Hextn. } eapply is_lim_seq_ext. ** intros n. rewrite Integral_plus; eauto. ** rewrite -(Integral_ext _ _ Hext); auto using ex_integral_plus. rewrite Integral_plus; eauto. eapply is_lim_seq_plus; eauto. { apply is_lim_seq_const. } rewrite //=. Qed. Lemma ae_equal_mult_indicator_compl_0: ∀ f U Hmeas, measurable f → μ (compl U) = 0 → almost_everywhere_meas μ (λ x, f x * wpt_fun (wpt_indicator U Hmeas) x = f x). Proof. intros g U Hmeas Hmeasg Heq0. eapply almost_everywhere_meas_mono; last first. { split; eauto. } { intros x. rewrite wpt_indicator_spec. intros. destruct excluded_middle_informative. * rewrite Rmult_1_r. done. * contradiction. } { apply measurable_fun_eq_inv; measurable. } Qed. Lemma ae_equal_mult_indicator_compl_0': ∀ f U Hmeas, measurable f → μ (compl U) = 0 → almost_everywhere_meas μ (λ x, f x = f x * wpt_fun (wpt_indicator U Hmeas) x). Proof. intros. eapply almost_everywhere_meas_ext; last eapply ae_equal_mult_indicator_compl_0; try eassumption. intros x. split; by symmetry; eauto. Qed. Lemma is_integral_levi_ae_ex fn f: measurable f → almost_everywhere_meas μ (λ x, is_lim_seq (λ n, fn n x) (f x : R)) → almost_everywhere_meas μ (λ x, ∀ n, fn n x <= fn (S n) x) → (∀ n, ex_integral (fn n)) → bound (λ r, ∃ n, is_integral (fn n) r) → ex_integral f ∧ is_lim_seq (λ n, Integral (fn n)) (Integral f). Proof. generalize ae_equal_mult_indicator_compl_0 => Hae. intros Hmeas Hlim Hmono Hex Hbound. specialize (almost_everywhere_meas_conj μ _ _ Hlim Hmono). intros (HF&Hμ0). apply sigma_closed_complements in HF. rewrite compl_involutive in HF * => HF. feed pose proof (is_integral_levi_ex (λ n, λ x, fn n x * wpt_fun (wpt_indicator _ HF) x) (λ x, f x * wpt_fun (wpt_indicator _ HF) x)) as Hlevi. { measurable. } { intros x. setoid_rewrite wpt_indicator_spec. destruct excluded_middle_informative as [(Hlim'&?)|Hnotin]. * setoid_rewrite Rmult_1_r. eauto. * setoid_rewrite Rmult_0_r. apply is_lim_seq_const. } { intros x n. rewrite wpt_indicator_spec. destruct excluded_middle_informative as [(Hlim'&?)|Hnotin]. * setoid_rewrite Rmult_1_r. eauto. * setoid_rewrite Rmult_0_r. reflexivity. } { intros n. eapply ex_integral_ae_ext; eauto. { eapply almost_everywhere_meas_ext; last eapply ae_equal_mult_indicator_compl_0. * intros ?; split; symmetry; eauto. * measurable. * eauto. } measurable. } { destruct Hbound as (r&Hub). exists r. intros ? (n&His). eapply is_integral_ae_ext in His; auto. eapply Hub; eauto. } destruct Hlevi as (Hlevi_ex&Hlevi_lim). assert (ex_integral f). { eapply ex_integral_ae_ext; eauto. eapply ae_equal_mult_indicator_compl_0; measurable. } split; auto. setoid_rewrite <-(Integral_ae_ext_weak) in Hlevi_lim; eauto. { eapply is_lim_seq_ext; last eauto. intros n => //=. symmetry. apply Integral_ae_ext_weak; eauto. { eapply almost_everywhere_meas_ext; last eapply ae_equal_mult_indicator_compl_0. * intros ?; split; symmetry; eauto. * measurable. * eauto. } measurable. } { eapply almost_everywhere_meas_ext; last eapply ae_equal_mult_indicator_compl_0. * intros ?; split; symmetry; eauto. * measurable. * eauto. } Qed. Lemma is_integral_levi_series_ae_ex fn: almost_everywhere_meas μ (λ x, ex_series (λ n, fn n x)) → (∀ n x, 0 <= fn n x) → (∀ n, ex_integral (fn n)) → bound (λ r, ∃ n, is_integral (λ x, sum_n (λ m, fn m x) n) r) → ex_integral (λ x, Series (λ n, fn n x)) ∧ is_series (λ n, Integral (fn n)) (Integral (λ x, (Series (λ n, fn n x )))). Proof. intros ? Hnonneg ??. destruct (is_integral_levi_ae_ex (λ n x, sum_n (λ m, fn m x) n) (λ x, Series (λ n, fn n x))). { apply measurable_Series; auto. } { eapply almost_everywhere_meas_ext; last eassumption. intros x. split. - intros ?%ex_series_is_lim_seq; eauto. - intros. eexists; eauto. } { eapply almost_everywhere_meas_True'. intros x n. rewrite sum_Sn. specialize (Hnonneg (S n) x). rewrite /plus => //=. nra. } { intros. eapply ex_integral_sum_n; intros; eauto. } { eauto. } split; eauto. eapply is_lim_seq_is_series; eauto. eapply is_lim_seq_ext; last eassumption. intros => //=. rewrite Integral_sum_n //=. Qed. Lemma is_integral_mct_ex fn f g: measurable f → (∀ x, is_lim_seq (λ n, fn n x) (f x : R)) → (∀ x, ∀ n, fn n x <= fn (S n) x) → (∀ x, ∀ n, Rabs (fn n x) <= g x) → (∀ n, ex_integral (fn n)) → ex_integral g → ex_integral f ∧ is_lim_seq (λ n, Integral (fn n)) (Integral f). Proof. intros Hmeas Hlim Hmono Hbounded Hex Hexg. edestruct (is_integral_levi_ex fn f); eauto. destruct Hexg as (v&Hisg). exists v. intros r (n&His). eapply (is_integral_mono (fn n) _ g); eauto. intros. specialize (Hbounded x n). move: Hbounded. apply Rabs_case; nra. Qed. Lemma is_integral_const k : is_integral (λ _, k) (k * μ (λ _, True)). Proof. setoid_rewrite <-(wpt_const_spec k) at 1. rewrite -wpt_integral_const. apply is_integral_wpt. Qed. Lemma ex_integral_const k : ex_integral (λ _, k). Proof. eexists. apply is_integral_const. Qed. Lemma Integral_const k : Integral (λ _, k) = (k * μ (λ _, True)). Proof. apply is_integral_unique, is_integral_const. Qed. Lemma measurable_non_ex_pos_integral_0 f: measurable f → ¬ ex_pos_integral f → Pos_integral f = 0. Proof. intros Hmeas Hnex. rewrite /Pos_integral. destruct excluded_middle_informative; auto. destruct excluded_middle_informative; auto. exfalso; apply Hnex; apply measurable_bounded_simple_ex_pos_integral; eauto. Qed. Lemma Integral_pos_mct fn f: measurable f → (∀ x, is_lim_seq (λ n, fn n x) (f x : R)) → (∀ x, ∀ n, 0 <= fn n x) → (∀ x, ∀ n, fn n x <= fn (S n) x) → (∀ n, ex_integral (fn n)) → real (Lim_seq (λ n, Integral (fn n))) = Integral f. Proof. intros Hmeas Hlim Hpos Hmono Hex. destruct (Classical_Prop.classic (bound (λ r, ∃ n, is_integral (fn n) r))) as [Hbound|Hunbounded]. { feed pose proof (is_integral_levi_ex fn f) as Hlevi; eauto. destruct Hlevi as (Hex_f&Hlim_int). apply is_lim_seq_unique in Hlim_int. rewrite Hlim_int. done. } transitivity 0. - cut (Lim_seq (λ n, Integral (fn n)) = p_infty). { intros ->. done. } apply is_lim_seq_unique. intros P Hlocal. rewrite /Rbar_locally in Hlocal. destruct Hlocal as (K&HK). assert (∃ n, K < Integral (fn n)) as (n&HKn). { apply Classical_Prop.NNPP. intros Hnex. apply Hunbounded. exists K. intros r (n&Heqr). apply Rnot_lt_le. intros Hlt. apply Hnex; exists n. apply is_integral_unique in Heqr as ->. done. } exists n. intros n' Hge. apply HK. eapply Rlt_le_trans; first eauto. clear -Hge Hmono Hex. induction Hge; first reflexivity. etransitivity; eauto. apply Integral_mono; eauto. - symmetry. assert (∀ x, 0 <= f x). { intros x. eapply is_lim_seq_pos; eauto. eauto. } rewrite Integral_equiv_Pos_integral //. assert (Hneg: ¬ ex_integral f). { intros (v&Hexf). apply Hunbounded. exists v. intros r (n&Heq). eapply (is_integral_mono (fn n) _ f _). - intros x. specialize (Hlim x). eapply is_lim_seq_incr_compare in Hlim; eauto. - done. - done. } apply measurable_non_ex_pos_integral_0; auto. intros Hex'. apply Hneg. apply ex_integral_equiv_pos_integral; eauto. Qed. Lemma is_lim_seq_Rmin_pos r: 0 <= r → is_lim_seq (λ n : nat, Rmin r (INR n)) r. Proof. intros Hle. edestruct archimed_pos as (k&?); eauto. intros P Hloc. exists (S k) => n Hle'. rewrite Rmin_left. - rewrite /Rbar_locally/locally in Hloc. destruct Hloc as (eps&HP). apply HP. apply ball_center. - transitivity (INR (S k)); first nra. apply le_INR. done. Qed. Lemma ex_integral_Rmin f: (∀ x, 0 <= f x) → measurable f → ∀ n, ex_integral (λ x, Rmin (f x) (INR n)). Proof. { intros Hpos Hmeas n. apply (ex_integral_mono_ex _ (λ x, INR n)). { intros x. rewrite Rabs_right; auto. apply Rmin_r. apply Rmin_case_strong; auto. intros. apply Rle_ge, pos_INR. } { apply measurable_Rmin; eauto. apply measurable_const. } { apply ex_integral_const. } } Qed. Lemma ex_integral_ex_finite_lim_min f: (∀ x, 0 <= f x) → measurable f → ex_finite_lim_seq (λ n, Integral (λ x, Rmin (f x) (INR n))) ↔ ex_integral f. Proof. intros Hpos Hmeas. assert (∀ n x, 0 <= Rmin (f x) (INR n)). { intros => //=. apply Rmin_case_strong; auto. intros. apply pos_INR. } generalize (ex_integral_Rmin _ Hpos Hmeas) => ?. split. - intros Hbounded. edestruct (is_integral_levi_pos_ex (λ n, λ x, Rmin (f x) (INR n))); eauto. { intros x => //=. eapply is_lim_seq_Rmin_pos; eauto. } { intros. apply Rle_min_compat_l. apply le_INR. auto. } destruct Hbounded as (r&Hub). exists r. intros z (n&His). rewrite -(is_integral_unique _ _ His). eapply (is_lim_seq_incr_compare (λ n, Integral (λ x, Rmin (f x) (INR n)))); eauto. intros n'. apply Integral_mono; eauto. intros x. apply Rle_min_compat_l, le_INR; lia. - intros (v&Hex). exists v. rewrite -(is_integral_unique _ _ Hex). edestruct (is_integral_mct_ex (λ n, (λ x, Rmin (f x) (INR n))) f f); eauto. { intros x => //=. apply is_lim_seq_Rmin_pos; eauto. } { intros. apply Rle_min_compat_l, le_INR; lia. } { rewrite //= => ??. apply Rmin_case_strong; intros; rewrite Rabs_right; try nra; eauto. apply Rle_ge, pos_INR. } eexists; eauto. Qed. Lemma ex_integral_sup_min f: (∀ x, 0 <= f x) → measurable f → bound (λ r, ∃ n, Integral (λ x, Rmin (f x) (INR n)) = r) ↔ ex_integral f. Proof. intros Hpos Hmeas. assert (∀ n x, 0 <= Rmin (f x) (INR n)). { intros => //=. apply Rmin_case_strong; auto. intros. apply pos_INR. } generalize (ex_integral_Rmin _ Hpos Hmeas) => ?. split. - intros Hbounded. edestruct (is_integral_levi_pos_ex (λ n, λ x, Rmin (f x) (INR n))); eauto. { intros x => //=. eapply is_lim_seq_Rmin_pos; eauto. } { intros. apply Rle_min_compat_l. apply le_INR. auto. } destruct Hbounded as (r&Hub). exists r. intros z (n&?). apply Hub. exists n. apply is_integral_unique; eauto. - intros (v&Hex). exists v. intros r (n&<-). rewrite -(is_integral_unique _ _ Hex). apply Integral_mono; eauto. intros; apply Rmin_l. eexists; eauto. Qed. Lemma is_integral_bound_measure_above f v t: (∀ x, 0 <= f x) → is_integral f v → 0 < t → μ (λ x, t <= f x) <= v / t. Proof. intros Hpos His Htpos. apply Rnot_gt_le. intros Hgt. cut (v < Integral f). { intros Hlt. rewrite (is_integral_unique _ _ His) in Hlt. nra. } apply (Rlt_le_trans _ (t * (μ (λ x, t <= f x)))). { apply (Rmult_lt_reg_r (/t)). { apply Rinv_0_lt_compat; nra. } { field_simplify; try nra. } } assert (Hm: F (λ x, t <= f x)). { apply measurable_fun_ge. eauto. } transitivity (Integral (wpt_fun (wpt_scal t (wpt_indicator _ Hm)))). { right. rewrite Integral_wpt wpt_integral_scal wpt_integral_indicator. done. } apply Integral_mono; eauto. - intros x. rewrite wpt_scal_spec wpt_indicator_spec. destruct excluded_middle_informative; auto; simpl; try nra. rewrite Rmult_0_r. eauto. - eexists; eauto. Qed. Lemma Integral_Rabs f: (ex_integral f ∨ (measurable f ∧ ex_integral (λ x, Rabs (f x)))) → Rabs (Integral f) <= Integral (λ x, (Rabs (f x))). Proof. intros Hex. assert (ex_integral f). { destruct Hex; auto. apply ex_integral_Rabs; intuition. } assert (ex_integral (λ x, Rabs (f x))). { destruct Hex; auto. - apply (ex_integral_Rabs f); eauto. - intuition. } apply Rabs_case => ?. - apply Integral_mono; eauto. intros. apply Rabs_case; nra. - replace (- Integral f) with (-1 * Integral f) by nra. rewrite -Integral_scal; eauto. apply Integral_mono; eauto. * intros. apply Rabs_case; nra. * by apply ex_integral_scal. Qed. Lemma is_integral_ae_ge0 f v: almost_everywhere_meas μ (λ x, f x >= 0) → is_integral f v → v >= 0. Proof. intros Hae His. destruct Hae as (Hmeas&Hmeas0). generalize (sigma_closed_complements _ F _ Hmeas). rewrite compl_involutive => HF. eapply (is_integral_ae_ext _ (λ x, f x * wpt_fun (wpt_indicator _ HF) x)) in His. { eapply is_integral_ge0; eauto. intros. rewrite //= wpt_indicator_spec. destruct excluded_middle_informative as [Hc|Hnc]; simpl; nra. } - eapply ae_equal_mult_indicator_compl_0'; auto. eauto. - measurable. eauto. Qed. Lemma is_integral_ae_mono f1 v1 f2 v2: almost_everywhere_meas μ (λ x, f1 x <= f2 x) → is_integral f1 v1 → is_integral f2 v2 → v1 <= v2. Proof. intros Hle Hint1 Hint2. cut (0 <= v2 - v1); first by nra. assert (His: is_integral (λ x, f2 x - f1 x) (v2 - v1)). { apply is_integral_minus; auto. } apply is_integral_ae_ge0 in His; first nra. eapply almost_everywhere_meas_ext; eauto. intros x; split; nra. Qed. Lemma Integral_ae_mono f1 f2: almost_everywhere_meas μ (λ x, f1 x <= f2 x) → ex_integral f1 → ex_integral f2 → Integral f1 <= Integral f2. Proof. intros Hmono (v1&Heq1) (v2&Heq2). rewrite (is_integral_unique _ _ Heq1). rewrite (is_integral_unique _ _ Heq2). eapply is_integral_ae_mono; eauto. Qed. Lemma ex_integral_ae_mono_ex f1 f2: almost_everywhere_meas μ (λ x, Rabs (f1 x) <= f2 x) → measurable f1 → ex_integral f2 → ex_integral f1. Proof. intros Hae Hmeas Hex. destruct Hae as (Hmeas'&Hneg). generalize (sigma_closed_complements _ _ _ Hmeas') => H'. setoid_rewrite compl_involutive in H'. cut (ex_integral (λ x, f2 x * wpt_fun (wpt_indicator _ H') x)). { intros Hex_indic. assert (Hex': ex_integral (λ x, f1 x * wpt_fun (wpt_indicator _ H') x)). { eapply ex_integral_mono_ex; last eapply Hex_indic. * intros x => //=. rewrite ?wpt_indicator_spec. destruct excluded_middle_informative; rewrite ?Rmult_1_r ?Rmult_0_r; try nra. rewrite Rabs_right; nra. * measurable. } eapply ex_integral_ae_ext; last eapply Hex'; auto. apply ae_equal_mult_indicator_compl_0; eauto. } eapply ex_integral_ae_ext; eauto. { eapply ae_equal_mult_indicator_compl_0'; eauto. } measurable. Qed. Lemma ex_integral_ex_integral_over U f : F U → ex_integral f → ex_integral_over U f. Proof. intros Hmeas Hex. rewrite /ex_integral_over/is_integral_over. efeed pose proof (ex_integral_ae_mono_ex (λ x : A, f x * (match excluded_middle_informative (U x) with | left _ => 1 | _ => 0 end)) (λ x, Rabs (f x))) as Hex'. - apply almost_everywhere_meas_True'. intros x. destruct (excluded_middle_informative (U x)); rewrite ?Rmult_1_r ?Rmult_0_r; auto. * nra. * rewrite Rabs_R0. apply Rabs_pos. - measurable. apply measurable_indicator; auto. - rewrite -ex_integral_Rabs; eauto. - destruct Hex' as (v&?). exists v. split; auto. Qed. End integral. Hint Resolve is_integral_measurable ex_integral_measurable ex_integral_wpt ex_integral_const. Arguments weighted_partition {_} _.
-- You can omit the right hand side if you pattern match on an empty type. But -- you have to do the matching. module NoRHSRequiresAbsurdPattern where data Zero : Set where good : {A : Set} -> Zero -> A good () bad : {A : Set} -> Zero -> A bad h
module Shape export data Shape = Triangle Double Double | Rectangle Double Double | Circle Double export triangle : Double -> Double -> Shape triangle = Triangle export rectangle : Double -> Double -> Shape rectangle = Rectangle export circle : Double -> Shape circle = Circle public export data ShapeView : Shape -> Type where STriangle : (base : Double) -> (height : Double) -> ShapeView (triangle base height) SRectangle : (width : Double) -> (height : Double) -> ShapeView (rectangle width height) SCircle : (radius : Double) -> ShapeView (circle radius) export shapeView : (shape : Shape) -> ShapeView shape shapeView (Triangle x y) = STriangle x y shapeView (Rectangle x y) = SRectangle x y shapeView (Circle x) = SCircle x
[STATEMENT] lemma wf\<^sub>s\<^sub>t\<^sub>s'_update\<^sub>s\<^sub>t_snd: assumes "wf\<^sub>s\<^sub>t\<^sub>s' \<S> \<A>" "send\<langle>ts\<rangle>\<^sub>s\<^sub>t#S \<in> \<S>" shows "wf\<^sub>s\<^sub>t\<^sub>s' (update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t#S)) (\<A>@[Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])" [PROOF STATE] proof (prove) goal (1 subgoal): 1. wf\<^sub>s\<^sub>t\<^sub>s' (update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S)) (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) [PROOF STEP] unfolding wf\<^sub>s\<^sub>t\<^sub>s'_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. (\<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S)) \<and> (\<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {}) \<and> (\<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {}) \<and> (\<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {}) [PROOF STEP] proof (intro conjI) [PROOF STATE] proof (state) goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] let ?S = "send\<langle>ts\<rangle>\<^sub>s\<^sub>t#S" [PROOF STATE] proof (state) goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] let ?A = "\<A>@[Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]" [PROOF STATE] proof (state) goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] have \<S>: "\<And>S'. S' \<in> update\<^sub>s\<^sub>t \<S> ?S \<Longrightarrow> S' = S \<or> S' \<in> \<S>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<And>S'. S' \<in> update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<Longrightarrow> S' = S \<or> S' \<in> \<S> [PROOF STEP] by auto [PROOF STATE] proof (state) this: ?S'2 \<in> update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<Longrightarrow> ?S'2 = S \<or> ?S'2 \<in> \<S> goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] have 1: "\<forall>S \<in> \<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S) [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: wf\<^sub>s\<^sub>t\<^sub>s' \<S> \<A> send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S) [PROOF STEP] unfolding wf\<^sub>s\<^sub>t\<^sub>s'_def [PROOF STATE] proof (prove) using this: (\<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S)) \<and> (\<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t \<A> = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t \<A> \<inter> bvars\<^sub>s\<^sub>t S = {}) send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S) [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S) goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] moreover [PROOF STATE] proof (state) this: \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S) goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] have 2: "wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t ?A = wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) [PROOF STEP] using wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t_split(2) [PROOF STATE] proof (prove) using this: wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (?S @ ?S') = wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t ?S \<union> wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t ?S' goal (1 subgoal): 1. wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) [PROOF STEP] by (auto simp add: Un_assoc) [PROOF STATE] proof (state) this: wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] ultimately [PROOF STATE] proof (chain) picking this: \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S) wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) [PROOF STEP] have 3: "\<forall>S \<in> \<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t ?A) (dual\<^sub>s\<^sub>t S)" [PROOF STATE] proof (prove) using this: \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S) wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) goal (1 subgoal): 1. \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) [PROOF STEP] by (metis wf_vars_mono) [PROOF STATE] proof (state) this: \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] have 4: "\<forall>S \<in> \<S>. \<forall>S' \<in> \<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: wf\<^sub>s\<^sub>t\<^sub>s' \<S> \<A> send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. \<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} [PROOF STEP] unfolding wf\<^sub>s\<^sub>t\<^sub>s'_def [PROOF STATE] proof (prove) using this: (\<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S)) \<and> (\<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t \<A> = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t \<A> \<inter> bvars\<^sub>s\<^sub>t S = {}) send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. \<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} [PROOF STEP] by simp [PROOF STATE] proof (state) this: \<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] have "wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t ?A) (dual\<^sub>s\<^sub>t S)" [PROOF STATE] proof (prove) goal (1 subgoal): 1. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) [PROOF STEP] using 1 2 3 assms(2) [PROOF STATE] proof (prove) using this: \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S) wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) \<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) [PROOF STEP] by auto [PROOF STATE] proof (state) this: wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) goal (4 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) 2. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 4. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] thus "\<forall>S \<in> update\<^sub>s\<^sub>t \<S> ?S. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t ?A) (dual\<^sub>s\<^sub>t S)" [PROOF STATE] proof (prove) using this: wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) goal (1 subgoal): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) [PROOF STEP] by (metis 3 \<S>) [PROOF STATE] proof (state) this: \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)])) (dual\<^sub>s\<^sub>t S) goal (3 subgoals): 1. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 2. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] have "fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S = {}" "\<forall>S' \<in> \<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {}" "\<forall>S' \<in> \<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t S = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S = {} &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] using 4 assms(2) [PROOF STATE] proof (prove) using this: \<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S = {} &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] unfolding wf\<^sub>s\<^sub>t\<^sub>s'_def [PROOF STATE] proof (prove) using this: \<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S = {} &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] by force+ [PROOF STATE] proof (state) this: fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S = {} \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t S = {} goal (3 subgoals): 1. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} 2. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 3. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] thus "\<forall>S \<in> update\<^sub>s\<^sub>t \<S> ?S. \<forall>S' \<in> update\<^sub>s\<^sub>t \<S> ?S. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {}" [PROOF STATE] proof (prove) using this: fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S = {} \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {} \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t S = {} goal (1 subgoal): 1. \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} [PROOF STEP] by (metis 4 \<S>) [PROOF STATE] proof (state) this: \<forall>Sa\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). \<forall>S'\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t Sa \<inter> bvars\<^sub>s\<^sub>t S' = {} goal (2 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 2. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] have "\<forall>S' \<in> \<S>. fv\<^sub>s\<^sub>t ?S \<inter> bvars\<^sub>s\<^sub>t S' = {}" "\<forall>S' \<in> \<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t ?S = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>s\<^sub>t S' = {} &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} [PROOF STEP] using assms [PROOF STATE] proof (prove) using this: wf\<^sub>s\<^sub>t\<^sub>s' \<S> \<A> send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>s\<^sub>t S' = {} &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} [PROOF STEP] unfolding wf\<^sub>s\<^sub>t\<^sub>s'_def [PROOF STATE] proof (prove) using this: (\<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S)) \<and> (\<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t \<A> = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t \<A> \<inter> bvars\<^sub>s\<^sub>t S = {}) send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>s\<^sub>t S' = {} &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} [PROOF STEP] by metis+ [PROOF STATE] proof (state) this: \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>s\<^sub>t S' = {} \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} goal (2 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 2. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] hence 5: "fv\<^sub>e\<^sub>s\<^sub>t ?A = fv\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts)" "bvars\<^sub>e\<^sub>s\<^sub>t ?A = bvars\<^sub>e\<^sub>s\<^sub>t \<A>" "\<forall>S' \<in> \<S>. fv\<^sub>s\<^sub>e\<^sub>t (set ts) \<inter> bvars\<^sub>s\<^sub>t S' = {}" [PROOF STATE] proof (prove) using this: \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>s\<^sub>t S' = {} \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} goal (1 subgoal): 1. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = fv\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) &&& bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = bvars\<^sub>e\<^sub>s\<^sub>t \<A> &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>e\<^sub>t (set ts) \<inter> bvars\<^sub>s\<^sub>t S' = {} [PROOF STEP] using to_st_append [PROOF STATE] proof (prove) using this: \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>s\<^sub>t S' = {} \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S' \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} to_st (?A @ ?B) = to_st ?A @ to_st ?B goal (1 subgoal): 1. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = fv\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) &&& bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = bvars\<^sub>e\<^sub>s\<^sub>t \<A> &&& \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>e\<^sub>t (set ts) \<inter> bvars\<^sub>s\<^sub>t S' = {} [PROOF STEP] by fastforce+ [PROOF STATE] proof (state) this: fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = fv\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = bvars\<^sub>e\<^sub>s\<^sub>t \<A> \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>e\<^sub>t (set ts) \<inter> bvars\<^sub>s\<^sub>t S' = {} goal (2 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 2. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] have *: "\<forall>S \<in> \<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t ?A = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} [PROOF STEP] using 5 assms(1) [PROOF STATE] proof (prove) using this: fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = fv\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = bvars\<^sub>e\<^sub>s\<^sub>t \<A> \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>e\<^sub>t (set ts) \<inter> bvars\<^sub>s\<^sub>t S' = {} wf\<^sub>s\<^sub>t\<^sub>s' \<S> \<A> goal (1 subgoal): 1. \<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} [PROOF STEP] unfolding wf\<^sub>s\<^sub>t\<^sub>s'_def [PROOF STATE] proof (prove) using this: fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = fv\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = bvars\<^sub>e\<^sub>s\<^sub>t \<A> \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>e\<^sub>t (set ts) \<inter> bvars\<^sub>s\<^sub>t S' = {} (\<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S)) \<and> (\<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t \<A> = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t \<A> \<inter> bvars\<^sub>s\<^sub>t S = {}) goal (1 subgoal): 1. \<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} [PROOF STEP] by fast [PROOF STATE] proof (state) this: \<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} goal (2 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 2. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] hence "fv\<^sub>s\<^sub>t ?S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t ?A = {}" [PROOF STATE] proof (prove) using this: \<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} goal (1 subgoal): 1. fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} [PROOF STEP] using assms(2) [PROOF STATE] proof (prove) using this: \<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} [PROOF STEP] by metis [PROOF STATE] proof (state) this: fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} goal (2 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 2. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] hence "fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t ?A = {}" [PROOF STATE] proof (prove) using this: fv\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} goal (1 subgoal): 1. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} [PROOF STEP] by auto [PROOF STATE] proof (state) this: fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} goal (2 subgoals): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} 2. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] thus "\<forall>S \<in> update\<^sub>s\<^sub>t \<S> ?S. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t ?A = {}" [PROOF STATE] proof (prove) using this: fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} goal (1 subgoal): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} [PROOF STEP] by (metis * \<S>) [PROOF STATE] proof (state) this: \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = {} goal (1 subgoal): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] have **: "\<forall>S \<in> \<S>. fv\<^sub>e\<^sub>s\<^sub>t ?A \<inter> bvars\<^sub>s\<^sub>t S = {}" [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] using 5 assms(1) [PROOF STATE] proof (prove) using this: fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = fv\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = bvars\<^sub>e\<^sub>s\<^sub>t \<A> \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>e\<^sub>t (set ts) \<inter> bvars\<^sub>s\<^sub>t S' = {} wf\<^sub>s\<^sub>t\<^sub>s' \<S> \<A> goal (1 subgoal): 1. \<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] unfolding wf\<^sub>s\<^sub>t\<^sub>s'_def [PROOF STATE] proof (prove) using this: fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = fv\<^sub>e\<^sub>s\<^sub>t \<A> \<union> fv\<^sub>s\<^sub>e\<^sub>t (set ts) bvars\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) = bvars\<^sub>e\<^sub>s\<^sub>t \<A> \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>e\<^sub>t (set ts) \<inter> bvars\<^sub>s\<^sub>t S' = {} (\<forall>S\<in>\<S>. wf\<^sub>s\<^sub>t (wfrestrictedvars\<^sub>e\<^sub>s\<^sub>t \<A>) (dual\<^sub>s\<^sub>t S)) \<and> (\<forall>S\<in>\<S>. \<forall>S'\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>s\<^sub>t S' = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>s\<^sub>t S \<inter> bvars\<^sub>e\<^sub>s\<^sub>t \<A> = {}) \<and> (\<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t \<A> \<inter> bvars\<^sub>s\<^sub>t S = {}) goal (1 subgoal): 1. \<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] by fast [PROOF STATE] proof (state) this: \<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} goal (1 subgoal): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] hence "fv\<^sub>e\<^sub>s\<^sub>t ?A \<inter> bvars\<^sub>s\<^sub>t ?S = {}" [PROOF STATE] proof (prove) using this: \<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} goal (1 subgoal): 1. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} [PROOF STEP] using assms(2) [PROOF STATE] proof (prove) using this: \<forall>S\<in>\<S>. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S \<in> \<S> goal (1 subgoal): 1. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} [PROOF STEP] by metis [PROOF STATE] proof (state) this: fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} goal (1 subgoal): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] hence "fv\<^sub>e\<^sub>s\<^sub>t ?A \<inter> bvars\<^sub>s\<^sub>t S = {}" [PROOF STATE] proof (prove) using this: fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S) = {} goal (1 subgoal): 1. fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] by fastforce [PROOF STATE] proof (state) this: fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} goal (1 subgoal): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] thus "\<forall>S \<in> update\<^sub>s\<^sub>t \<S> ?S. fv\<^sub>e\<^sub>s\<^sub>t ?A \<inter> bvars\<^sub>s\<^sub>t S = {}" [PROOF STATE] proof (prove) using this: fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} goal (1 subgoal): 1. \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} [PROOF STEP] by (metis ** \<S>) [PROOF STATE] proof (state) this: \<forall>S\<in>update\<^sub>s\<^sub>t \<S> (send\<langle>ts\<rangle>\<^sub>s\<^sub>t # S). fv\<^sub>e\<^sub>s\<^sub>t (\<A> @ [Step (receive\<langle>ts\<rangle>\<^sub>s\<^sub>t)]) \<inter> bvars\<^sub>s\<^sub>t S = {} goal: No subgoals! [PROOF STEP] qed
The band first became involved with Sarajevo in 1993 on their Zoo TV Tour ; approached by aid worker Bill Carter about bringing attention to the Siege of Sarajevo , the band conducted nightly satellite transmissions with Bosnians during their shows . These link @-@ ups were the subject of criticism from journalists for mixing entertainment with human tragedy . Although the war made it impractical for U2 to visit Sarajevo at the time , they vowed to eventually play a concert in the city . After the conflict ended in November 1995 , they made arrangements to visit Sarajevo , and with help from United Nations ambassadors and peacekeeping troops , they scheduled and played the concert in 1997 .
[STATEMENT] lemma LK_\<sigma>23_is_ntcf: assumes "\<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA>" and "\<TT> : cat_ordinal (2\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA>" and "\<eta>' : \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' \<circ>\<^sub>C\<^sub>F \<KK>23 : cat_ordinal (2\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA>" shows "LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] proof- [PROOF STATE] proof (state) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] interpret \<FF>': is_functor \<alpha> \<open>cat_ordinal (3\<^sub>\<nat>)\<close> \<AA> \<FF>' [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] by (rule assms(1)) [PROOF STATE] proof (state) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] interpret \<TT>: is_functor \<alpha> \<open>cat_ordinal (2\<^sub>\<nat>)\<close> \<AA> \<TT> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<TT> : cat_ordinal (2\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] by (rule assms(2)) [PROOF STATE] proof (state) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] interpret \<eta>': is_ntcf \<alpha> \<open>cat_ordinal (2\<^sub>\<nat>)\<close> \<AA> \<TT> \<open>\<FF>' \<circ>\<^sub>C\<^sub>F \<KK>23\<close> \<eta>' [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<eta>' : \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<KK>23 : cat_ordinal (2\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] by (rule assms(3)) [PROOF STATE] proof (state) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] interpret \<KK>23: is_functor \<alpha> \<open>cat_ordinal (2\<^sub>\<nat>)\<close> \<open>cat_ordinal (3\<^sub>\<nat>)\<close> \<open>\<KK>23\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. \<KK>23 : cat_ordinal (2\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> cat_ordinal (3\<^sub>\<nat>) [PROOF STEP] by (cs_concl cs_shallow cs_intro: cat_cs_intros cat_Kan_cs_intros) [PROOF STATE] proof (state) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] interpret LK23: is_functor \<alpha> \<open>cat_ordinal (3\<^sub>\<nat>)\<close> \<AA> \<open>LK23 \<TT>\<close> [PROOF STATE] proof (prove) goal (1 subgoal): 1. LK23 \<TT> : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] by (cs_concl cs_intro: cat_Kan_cs_intros cat_cs_intros) [PROOF STATE] proof (state) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] show ?thesis [PROOF STATE] proof (prove) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> [PROOF STEP] proof(rule is_ntcfI') [PROOF STATE] proof (state) goal (13 subgoals): 1. \<Z> \<alpha> 2. vfsequence (LK_\<sigma>23 \<TT> \<eta>' \<FF>') 3. vcard (LK_\<sigma>23 \<TT> \<eta>' \<FF>') = 5\<^sub>\<nat> 4. LK23 \<TT> : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 5. \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 6. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDom\<rparr> = LK23 \<TT> 7. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTCod\<rparr> = \<FF>' 8. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGDom\<rparr> = cat_ordinal (3\<^sub>\<nat>) 9. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGCod\<rparr> = \<AA> 10. vsv (LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>) A total of 13 subgoals... [PROOF STEP] show "vfsequence (LK_\<sigma>23 \<TT> \<eta>' \<FF>')" [PROOF STATE] proof (prove) goal (1 subgoal): 1. vfsequence (LK_\<sigma>23 \<TT> \<eta>' \<FF>') [PROOF STEP] unfolding LK_\<sigma>23_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. vfsequence [\<lambda>a\<in>\<^sub>\<circ>cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr>. if a = []\<^sub>\<circ> \<Rightarrow> \<eta>'\<lparr>NTMap\<rparr>\<lparr>[]\<^sub>\<circ>\<rparr> | a = 1\<^sub>\<nat> \<Rightarrow> []\<^sub>\<circ> \<otimes>\<^sub>H\<^sub>M\<^sub>.\<^sub>A\<^bsub>\<FF>'\<^esub> 1\<^sub>\<nat> \<circ>\<^sub>A\<^bsub>\<TT>\<lparr>HomCod\<rparr>\<^esub> \<eta>'\<lparr>NTMap\<rparr>\<lparr>[]\<^sub>\<circ>\<rparr> | a = 2\<^sub>\<nat> \<Rightarrow> \<eta>'\<lparr>NTMap\<rparr>\<lparr>1\<^sub>\<nat>\<rparr> | otherwise \<Rightarrow> \<TT>\<lparr>HomCod\<rparr>\<lparr>Arr\<rparr>, LK23 \<TT>, \<FF>', cat_ordinal (3\<^sub>\<nat>), \<FF>'\<lparr>HomCod\<rparr>]\<^sub>\<circ> [PROOF STEP] by simp [PROOF STATE] proof (state) this: vfsequence (LK_\<sigma>23 \<TT> \<eta>' \<FF>') goal (12 subgoals): 1. \<Z> \<alpha> 2. vcard (LK_\<sigma>23 \<TT> \<eta>' \<FF>') = 5\<^sub>\<nat> 3. LK23 \<TT> : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 4. \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 5. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDom\<rparr> = LK23 \<TT> 6. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTCod\<rparr> = \<FF>' 7. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGDom\<rparr> = cat_ordinal (3\<^sub>\<nat>) 8. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGCod\<rparr> = \<AA> 9. vsv (LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>) 10. \<D>\<^sub>\<circ> (LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>) = cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr> A total of 12 subgoals... [PROOF STEP] show "vcard (LK_\<sigma>23 \<TT> \<eta>' \<FF>') = 5\<^sub>\<nat>" [PROOF STATE] proof (prove) goal (1 subgoal): 1. vcard (LK_\<sigma>23 \<TT> \<eta>' \<FF>') = 5\<^sub>\<nat> [PROOF STEP] unfolding LK_\<sigma>23_def [PROOF STATE] proof (prove) goal (1 subgoal): 1. vcard [\<lambda>a\<in>\<^sub>\<circ>cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr>. if a = []\<^sub>\<circ> \<Rightarrow> \<eta>'\<lparr>NTMap\<rparr>\<lparr>[]\<^sub>\<circ>\<rparr> | a = 1\<^sub>\<nat> \<Rightarrow> []\<^sub>\<circ> \<otimes>\<^sub>H\<^sub>M\<^sub>.\<^sub>A\<^bsub>\<FF>'\<^esub> 1\<^sub>\<nat> \<circ>\<^sub>A\<^bsub>\<TT>\<lparr>HomCod\<rparr>\<^esub> \<eta>'\<lparr>NTMap\<rparr>\<lparr>[]\<^sub>\<circ>\<rparr> | a = 2\<^sub>\<nat> \<Rightarrow> \<eta>'\<lparr>NTMap\<rparr>\<lparr>1\<^sub>\<nat>\<rparr> | otherwise \<Rightarrow> \<TT>\<lparr>HomCod\<rparr>\<lparr>Arr\<rparr>, LK23 \<TT>, \<FF>', cat_ordinal (3\<^sub>\<nat>), \<FF>'\<lparr>HomCod\<rparr>]\<^sub>\<circ> = 5\<^sub>\<nat> [PROOF STEP] by (simp_all add: nat_omega_simps) [PROOF STATE] proof (state) this: vcard (LK_\<sigma>23 \<TT> \<eta>' \<FF>') = 5\<^sub>\<nat> goal (11 subgoals): 1. \<Z> \<alpha> 2. LK23 \<TT> : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 3. \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 4. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDom\<rparr> = LK23 \<TT> 5. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTCod\<rparr> = \<FF>' 6. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGDom\<rparr> = cat_ordinal (3\<^sub>\<nat>) 7. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGCod\<rparr> = \<AA> 8. vsv (LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>) 9. \<D>\<^sub>\<circ> (LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>) = cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr> 10. \<And>a. a \<in>\<^sub>\<circ> cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr> \<Longrightarrow> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> : LK23 \<TT>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> \<mapsto>\<^bsub>\<AA>\<^esub> \<FF>'\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> A total of 11 subgoals... [PROOF STEP] show "LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> : LK23 \<TT>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> \<mapsto>\<^bsub>\<AA>\<^esub> \<FF>'\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>" if "a \<in>\<^sub>\<circ> cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr>" for a [PROOF STATE] proof (prove) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> : LK23 \<TT>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> \<mapsto>\<^bsub>\<AA>\<^esub> \<FF>'\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> [PROOF STEP] proof- [PROOF STATE] proof (state) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> : LK23 \<TT>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> \<mapsto>\<^bsub>\<AA>\<^esub> \<FF>'\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> [PROOF STEP] from that [PROOF STATE] proof (chain) picking this: a \<in>\<^sub>\<circ> cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr> [PROOF STEP] consider \<open>a = 0\<close> | \<open>a = 1\<^sub>\<nat>\<close> | \<open>a = 2\<^sub>\<nat>\<close> [PROOF STATE] proof (prove) using this: a \<in>\<^sub>\<circ> cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr> goal (1 subgoal): 1. \<lbrakk>a = []\<^sub>\<circ> \<Longrightarrow> thesis; a = 1\<^sub>\<nat> \<Longrightarrow> thesis; a = 2\<^sub>\<nat> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] unfolding cat_ordinal_cs_simps three [PROOF STATE] proof (prove) using this: a \<in>\<^sub>\<circ> ZFC_in_HOL.set {[]\<^sub>\<circ>, 1\<^sub>\<nat>, 2\<^sub>\<nat>} goal (1 subgoal): 1. \<lbrakk>a = []\<^sub>\<circ> \<Longrightarrow> thesis; a = 1\<^sub>\<nat> \<Longrightarrow> thesis; a = 2\<^sub>\<nat> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis [PROOF STEP] by auto [PROOF STATE] proof (state) this: \<lbrakk>a = []\<^sub>\<circ> \<Longrightarrow> ?thesis; a = 1\<^sub>\<nat> \<Longrightarrow> ?thesis; a = 2\<^sub>\<nat> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> : LK23 \<TT>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> \<mapsto>\<^bsub>\<AA>\<^esub> \<FF>'\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> [PROOF STEP] from this 0123 [PROOF STATE] proof (chain) picking this: \<lbrakk>a = []\<^sub>\<circ> \<Longrightarrow> ?thesis; a = 1\<^sub>\<nat> \<Longrightarrow> ?thesis; a = 2\<^sub>\<nat> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis []\<^sub>\<circ> \<in>\<^sub>\<circ> 2\<^sub>\<nat> 1\<^sub>\<nat> \<in>\<^sub>\<circ> 2\<^sub>\<nat> []\<^sub>\<circ> \<in>\<^sub>\<circ> 3\<^sub>\<nat> 1\<^sub>\<nat> \<in>\<^sub>\<circ> 3\<^sub>\<nat> 2\<^sub>\<nat> \<in>\<^sub>\<circ> 3\<^sub>\<nat> [PROOF STEP] show "LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> : LK23 \<TT>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> \<mapsto>\<^bsub>\<AA>\<^esub> \<FF>'\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>" [PROOF STATE] proof (prove) using this: \<lbrakk>a = []\<^sub>\<circ> \<Longrightarrow> ?thesis; a = 1\<^sub>\<nat> \<Longrightarrow> ?thesis; a = 2\<^sub>\<nat> \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis []\<^sub>\<circ> \<in>\<^sub>\<circ> 2\<^sub>\<nat> 1\<^sub>\<nat> \<in>\<^sub>\<circ> 2\<^sub>\<nat> []\<^sub>\<circ> \<in>\<^sub>\<circ> 3\<^sub>\<nat> 1\<^sub>\<nat> \<in>\<^sub>\<circ> 3\<^sub>\<nat> 2\<^sub>\<nat> \<in>\<^sub>\<circ> 3\<^sub>\<nat> goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> : LK23 \<TT>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> \<mapsto>\<^bsub>\<AA>\<^esub> \<FF>'\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> [PROOF STEP] by (cases, use nothing in \<open>simp_all only:\<close>) ( cs_concl cs_simp: cat_cs_simps cat_ordinal_cs_simps cat_Kan_cs_simps cs_intro: cat_cs_intros cat_ordinal_cs_intros cat_Kan_cs_intros nat_omega_intros )+ [PROOF STATE] proof (state) this: LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> : LK23 \<TT>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> \<mapsto>\<^bsub>\<AA>\<^esub> \<FF>'\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> goal: No subgoals! [PROOF STEP] qed [PROOF STATE] proof (state) this: ?a \<in>\<^sub>\<circ> cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr> \<Longrightarrow> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>?a\<rparr> : LK23 \<TT>\<lparr>ObjMap\<rparr>\<lparr>?a\<rparr> \<mapsto>\<^bsub>\<AA>\<^esub> \<FF>'\<lparr>ObjMap\<rparr>\<lparr>?a\<rparr> goal (10 subgoals): 1. \<Z> \<alpha> 2. LK23 \<TT> : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 3. \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 4. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDom\<rparr> = LK23 \<TT> 5. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTCod\<rparr> = \<FF>' 6. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGDom\<rparr> = cat_ordinal (3\<^sub>\<nat>) 7. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGCod\<rparr> = \<AA> 8. vsv (LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>) 9. \<D>\<^sub>\<circ> (LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>) = cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr> 10. \<And>a b f. f : a \<mapsto>\<^bsub>cat_ordinal (3\<^sub>\<nat>)\<^esub> b \<Longrightarrow> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>b\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK23 \<TT>\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> = \<FF>'\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> [PROOF STEP] show "LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>b\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK23 \<TT>\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> = \<FF>'\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr>" if "f : a \<mapsto>\<^bsub>cat_ordinal (3\<^sub>\<nat>)\<^esub> b" for a b f [PROOF STATE] proof (prove) goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>b\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK23 \<TT>\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> = \<FF>'\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> [PROOF STEP] using that 0123 [PROOF STATE] proof (prove) using this: f : a \<mapsto>\<^bsub>cat_ordinal (3\<^sub>\<nat>)\<^esub> b []\<^sub>\<circ> \<in>\<^sub>\<circ> 2\<^sub>\<nat> 1\<^sub>\<nat> \<in>\<^sub>\<circ> 2\<^sub>\<nat> []\<^sub>\<circ> \<in>\<^sub>\<circ> 3\<^sub>\<nat> 1\<^sub>\<nat> \<in>\<^sub>\<circ> 3\<^sub>\<nat> 2\<^sub>\<nat> \<in>\<^sub>\<circ> 3\<^sub>\<nat> goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>b\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK23 \<TT>\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> = \<FF>'\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> [PROOF STEP] (*very slow*) [PROOF STATE] proof (prove) using this: f : a \<mapsto>\<^bsub>cat_ordinal (3\<^sub>\<nat>)\<^esub> b []\<^sub>\<circ> \<in>\<^sub>\<circ> 2\<^sub>\<nat> 1\<^sub>\<nat> \<in>\<^sub>\<circ> 2\<^sub>\<nat> []\<^sub>\<circ> \<in>\<^sub>\<circ> 3\<^sub>\<nat> 1\<^sub>\<nat> \<in>\<^sub>\<circ> 3\<^sub>\<nat> 2\<^sub>\<nat> \<in>\<^sub>\<circ> 3\<^sub>\<nat> goal (1 subgoal): 1. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>b\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK23 \<TT>\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> = \<FF>'\<lparr>ArrMap\<rparr>\<lparr>f\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>a\<rparr> [PROOF STEP] by (elim cat_ordinal_3_is_arrE, use nothing in \<open>simp_all only:\<close>) ( cs_concl cs_simp: cat_cs_simps cat_ordinal_cs_simps \<FF>'.cf_ArrMap_Comp[symmetric] \<FF>'.HomCod.cat_Comp_assoc[symmetric] \<eta>'.ntcf_Comp_commute cat_Kan_cs_simps cs_intro: cat_cs_intros cat_ordinal_cs_intros nat_omega_intros )+ [PROOF STATE] proof (state) this: ?f : ?a \<mapsto>\<^bsub>cat_ordinal (3\<^sub>\<nat>)\<^esub> ?b \<Longrightarrow> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>?b\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK23 \<TT>\<lparr>ArrMap\<rparr>\<lparr>?f\<rparr> = \<FF>'\<lparr>ArrMap\<rparr>\<lparr>?f\<rparr> \<circ>\<^sub>A\<^bsub>\<AA>\<^esub> LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>\<lparr>?a\<rparr> goal (9 subgoals): 1. \<Z> \<alpha> 2. LK23 \<TT> : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 3. \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> 4. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDom\<rparr> = LK23 \<TT> 5. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTCod\<rparr> = \<FF>' 6. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGDom\<rparr> = cat_ordinal (3\<^sub>\<nat>) 7. LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTDGCod\<rparr> = \<AA> 8. vsv (LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>) 9. \<D>\<^sub>\<circ> (LK_\<sigma>23 \<TT> \<eta>' \<FF>'\<lparr>NTMap\<rparr>) = cat_ordinal (3\<^sub>\<nat>)\<lparr>Obj\<rparr> [PROOF STEP] qed ( cs_concl cs_simp: cat_Kan_cs_simps cs_intro: cat_cs_intros cat_Kan_cs_intros )+ [PROOF STATE] proof (state) this: LK_\<sigma>23 \<TT> \<eta>' \<FF>' : LK23 \<TT> \<mapsto>\<^sub>C\<^sub>F \<FF>' : cat_ordinal (3\<^sub>\<nat>) \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<AA> goal: No subgoals! [PROOF STEP] qed
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import field_theory.subfield import field_theory.tower import ring_theory.algebraic /-! # Intermediate fields Let `L / K` be a field extension, given as an instance `algebra K L`. This file defines the type of fields in between `K` and `L`, `intermediate_field K L`. An `intermediate_field K L` is a subfield of `L` which contains (the image of) `K`, i.e. it is a `subfield L` and a `subalgebra K L`. ## Main definitions * `intermediate_field K L` : the type of intermediate fields between `K` and `L`. * `subalgebra.to_intermediate_field`: turns a subalgebra closed under `⁻¹` into an intermediate field * `subfield.to_intermediate_field`: turns a subfield containing the image of `K` into an intermediate field * `intermediate_field.map`: map an intermediate field along an `alg_hom` ## Implementation notes Intermediate fields are defined with a structure extending `subfield` and `subalgebra`. A `subalgebra` is closed under all operations except `⁻¹`, ## Tags intermediate field, field extension -/ open finite_dimensional open_locale big_operators variables (K L : Type*) [field K] [field L] [algebra K L] section set_option old_structure_cmd true /-- `S : intermediate_field K L` is a subset of `L` such that there is a field tower `L / S / K`. -/ structure intermediate_field extends subalgebra K L, subfield L /-- Reinterpret an `intermediate_field` as a `subalgebra`. -/ add_decl_doc intermediate_field.to_subalgebra /-- Reinterpret an `intermediate_field` as a `subfield`. -/ add_decl_doc intermediate_field.to_subfield end variables {K L} (S : intermediate_field K L) namespace intermediate_field instance : set_like (intermediate_field K L) L := ⟨intermediate_field.carrier, λ p q h, by cases p; cases q; congr'⟩ @[simp] lemma mem_carrier {s : intermediate_field K L} {x : L} : x ∈ s.carrier ↔ x ∈ s := iff.rfl /-- Two intermediate fields are equal if they have the same elements. -/ @[ext] theorem ext {S T : intermediate_field K L} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T := set_like.ext h @[simp] lemma coe_to_subalgebra : (S.to_subalgebra : set L) = S := rfl @[simp] lemma coe_to_subfield : (S.to_subfield : set L) = S := rfl @[simp] lemma mem_mk (s : set L) (hK : ∀ x, algebra_map K L x ∈ s) (ho hm hz ha hn hi) (x : L) : x ∈ intermediate_field.mk s ho hm hz ha hK hn hi ↔ x ∈ s := iff.rfl @[simp] lemma mem_to_subalgebra (s : intermediate_field K L) (x : L) : x ∈ s.to_subalgebra ↔ x ∈ s := iff.rfl @[simp] lemma mem_to_subfield (s : intermediate_field K L) (x : L) : x ∈ s.to_subfield ↔ x ∈ s := iff.rfl /-- An intermediate field contains the image of the smaller field. -/ theorem algebra_map_mem (x : K) : algebra_map K L x ∈ S := S.algebra_map_mem' x /-- An intermediate field contains the ring's 1. -/ theorem one_mem : (1 : L) ∈ S := S.one_mem' /-- An intermediate field contains the ring's 0. -/ theorem zero_mem : (0 : L) ∈ S := S.zero_mem' /-- An intermediate field is closed under multiplication. -/ theorem mul_mem : ∀ {x y : L}, x ∈ S → y ∈ S → x * y ∈ S := S.mul_mem' /-- An intermediate field is closed under scalar multiplication. -/ /-- An intermediate field is closed under addition. -/ theorem add_mem : ∀ {x y : L}, x ∈ S → y ∈ S → x + y ∈ S := S.add_mem' /-- An intermediate field is closed under subtraction -/ theorem sub_mem {x y : L} (hx : x ∈ S) (hy : y ∈ S) : x - y ∈ S := S.to_subfield.sub_mem hx hy /-- An intermediate field is closed under negation. -/ theorem neg_mem : ∀ {x : L}, x ∈ S → -x ∈ S := S.neg_mem' /-- An intermediate field is closed under inverses. -/ theorem inv_mem : ∀ {x : L}, x ∈ S → x⁻¹ ∈ S := S.inv_mem' /-- An intermediate field is closed under division. -/ theorem div_mem {x y : L} (hx : x ∈ S) (hy : y ∈ S) : x / y ∈ S := S.to_subfield.div_mem hx hy /-- Product of a list of elements in an intermediate_field is in the intermediate_field. -/ lemma list_prod_mem {l : list L} : (∀ x ∈ l, x ∈ S) → l.prod ∈ S := S.to_subfield.list_prod_mem /-- Sum of a list of elements in an intermediate field is in the intermediate_field. -/ lemma list_sum_mem {l : list L} : (∀ x ∈ l, x ∈ S) → l.sum ∈ S := S.to_subfield.list_sum_mem /-- Product of a multiset of elements in an intermediate field is in the intermediate_field. -/ lemma multiset_prod_mem (m : multiset L) : (∀ a ∈ m, a ∈ S) → m.prod ∈ S := S.to_subfield.multiset_prod_mem m /-- Sum of a multiset of elements in a `intermediate_field` is in the `intermediate_field`. -/ lemma multiset_sum_mem (m : multiset L) : (∀ a ∈ m, a ∈ S) → m.sum ∈ S := S.to_subfield.multiset_sum_mem m /-- Product of elements of an intermediate field indexed by a `finset` is in the intermediate_field. -/ lemma prod_mem {ι : Type*} {t : finset ι} {f : ι → L} (h : ∀ c ∈ t, f c ∈ S) : ∏ i in t, f i ∈ S := S.to_subfield.prod_mem h /-- Sum of elements in a `intermediate_field` indexed by a `finset` is in the `intermediate_field`. -/ lemma sum_mem {ι : Type*} {t : finset ι} {f : ι → L} (h : ∀ c ∈ t, f c ∈ S) : ∑ i in t, f i ∈ S := S.to_subfield.sum_mem h lemma pow_mem {x : L} (hx : x ∈ S) : ∀ (n : ℤ), x^n ∈ S | (n : ℕ) := by { rw gpow_coe_nat, exact @is_submonoid.pow_mem L _ S.to_subfield.to_submonoid x _ hx n, } | -[1+ n] := by { rw [gpow_neg_succ_of_nat], have h := @is_submonoid.pow_mem L _ S.to_subfield.to_submonoid x _ hx _, exact subfield.inv_mem S.to_subfield h } lemma gsmul_mem {x : L} (hx : x ∈ S) (n : ℤ) : n • x ∈ S := S.to_subfield.gsmul_mem hx n lemma coe_int_mem (n : ℤ) : (n : L) ∈ S := by simp only [← gsmul_one, gsmul_mem, one_mem] end intermediate_field /-- Turn a subalgebra closed under inverses into an intermediate field -/ def subalgebra.to_intermediate_field (S : subalgebra K L) (inv_mem : ∀ x ∈ S, x⁻¹ ∈ S) : intermediate_field K L := { neg_mem' := λ x, S.neg_mem, inv_mem' := inv_mem, .. S } @[simp] lemma to_subalgebra_to_intermediate_field (S : subalgebra K L) (inv_mem : ∀ x ∈ S, x⁻¹ ∈ S) : (S.to_intermediate_field inv_mem).to_subalgebra = S := by { ext, refl } @[simp] lemma to_intermediate_field_to_subalgebra (S : intermediate_field K L) (inv_mem : ∀ x ∈ S.to_subalgebra, x⁻¹ ∈ S) : S.to_subalgebra.to_intermediate_field inv_mem = S := by { ext, refl } /-- Turn a subfield of `L` containing the image of `K` into an intermediate field -/ def subfield.to_intermediate_field (S : subfield L) (algebra_map_mem : ∀ x, algebra_map K L x ∈ S) : intermediate_field K L := { algebra_map_mem' := algebra_map_mem, .. S } namespace intermediate_field /-- An intermediate field inherits a field structure -/ instance to_field : field S := S.to_subfield.to_field @[simp, norm_cast] lemma coe_add (x y : S) : (↑(x + y) : L) = ↑x + ↑y := rfl @[simp, norm_cast] lemma coe_neg (x : S) : (↑(-x) : L) = -↑x := rfl @[simp, norm_cast] lemma coe_mul (x y : S) : (↑(x * y) : L) = ↑x * ↑y := rfl @[simp, norm_cast] lemma coe_inv (x : S) : (↑(x⁻¹) : L) = (↑x)⁻¹ := rfl @[simp, norm_cast] lemma coe_zero : ((0 : S) : L) = 0 := rfl @[simp, norm_cast] lemma coe_one : ((1 : S) : L) = 1 := rfl @[simp, norm_cast] lemma coe_pow (x : S) (n : ℕ) : (↑(x ^ n) : L) = ↑x ^ n := begin induction n with n ih, { simp }, { simp [pow_succ, ih] } end instance algebra : algebra K S := S.to_subalgebra.algebra instance to_algebra : algebra S L := S.to_subalgebra.to_algebra instance : is_scalar_tower K S L := is_scalar_tower.subalgebra' _ _ _ S.to_subalgebra variables {L' : Type*} [field L'] [algebra K L'] /-- If `f : L →+* L'` fixes `K`, `S.map f` is the intermediate field between `L'` and `K` such that `x ∈ S ↔ f x ∈ S.map f`. -/ def map (f : L →ₐ[K] L') : intermediate_field K L' := { inv_mem' := by { rintros _ ⟨x, hx, rfl⟩, exact ⟨x⁻¹, S.inv_mem hx, f.map_inv x⟩ }, neg_mem' := λ x hx, (S.to_subalgebra.map f).neg_mem hx, .. S.to_subalgebra.map f} /-- The embedding from an intermediate field of `L / K` to `L`. -/ def val : S →ₐ[K] L := S.to_subalgebra.val @[simp] theorem coe_val : ⇑S.val = coe := rfl @[simp] lemma val_mk {x : L} (hx : x ∈ S) : S.val ⟨x, hx⟩ = x := rfl variables {S} lemma to_subalgebra_injective {S S' : intermediate_field K L} (h : S.to_subalgebra = S'.to_subalgebra) : S = S' := by { ext, rw [← mem_to_subalgebra, ← mem_to_subalgebra, h] } variables (S) lemma set_range_subset : set.range (algebra_map K L) ⊆ S := S.to_subalgebra.range_subset lemma field_range_le : (algebra_map K L).field_range ≤ S.to_subfield := λ x hx, S.to_subalgebra.range_subset (by rwa [set.mem_range, ← ring_hom.mem_field_range]) @[simp] lemma to_subalgebra_le_to_subalgebra {S S' : intermediate_field K L} : S.to_subalgebra ≤ S'.to_subalgebra ↔ S ≤ S' := iff.rfl @[simp] lemma to_subalgebra_lt_to_subalgebra {S S' : intermediate_field K L} : S.to_subalgebra < S'.to_subalgebra ↔ S < S' := iff.rfl variables {S} section tower /-- Lift an intermediate_field of an intermediate_field -/ def lift1 {F : intermediate_field K L} (E : intermediate_field K F) : intermediate_field K L := map E (val F) /-- Lift an intermediate_field of an intermediate_field -/ def lift2 {F : intermediate_field K L} (E : intermediate_field F L) : intermediate_field K L := { carrier := E.carrier, zero_mem' := zero_mem E, add_mem' := λ x y, add_mem E, neg_mem' := λ x, neg_mem E, one_mem' := one_mem E, mul_mem' := λ x y, mul_mem E, inv_mem' := λ x, inv_mem E, algebra_map_mem' := λ x, algebra_map_mem E (algebra_map K F x) } instance has_lift1 {F : intermediate_field K L} : has_lift_t (intermediate_field K F) (intermediate_field K L) := ⟨lift1⟩ instance has_lift2 {F : intermediate_field K L} : has_lift_t (intermediate_field F L) (intermediate_field K L) := ⟨lift2⟩ @[simp] lemma mem_lift2 {F : intermediate_field K L} {E : intermediate_field F L} {x : L} : x ∈ (↑E : intermediate_field K L) ↔ x ∈ E := iff.rfl instance lift2_alg {F : intermediate_field K L} {E : intermediate_field F L} : algebra K E := { to_fun := (algebra_map F E).comp (algebra_map K F), map_zero' := ((algebra_map F E).comp (algebra_map K F)).map_zero, map_one' := ((algebra_map F E).comp (algebra_map K F)).map_one, map_add' := ((algebra_map F E).comp (algebra_map K F)).map_add, map_mul' := ((algebra_map F E).comp (algebra_map K F)).map_mul, smul := λ a b, (((algebra_map F E).comp (algebra_map K F)) a) * b, smul_def' := λ _ _, rfl, commutes' := λ a b, mul_comm (((algebra_map F E).comp (algebra_map K F)) a) b } instance lift2_tower {F : intermediate_field K L} {E : intermediate_field F L} : is_scalar_tower K F E := ⟨λ a b c, by { simp only [algebra.smul_def, ring_hom.map_mul, mul_assoc], refl }⟩ /-- `lift2` is isomorphic to the original `intermediate_field`. -/ def lift2_alg_equiv {F : intermediate_field K L} (E : intermediate_field F L) : (↑E : intermediate_field K L) ≃ₐ[K] E := { to_fun := λ x, x, inv_fun := λ x, x, left_inv := λ x, rfl, right_inv := λ x, rfl, map_add' := λ x y, rfl, map_mul' := λ x y, rfl, commutes' := λ x, rfl } end tower section finite_dimensional variables (F E : intermediate_field K L) instance finite_dimensional_left [finite_dimensional K L] : finite_dimensional K F := finite_dimensional.finite_dimensional_submodule F.to_subalgebra.to_submodule instance finite_dimensional_right [finite_dimensional K L] : finite_dimensional F L := right K F L @[simp] lemma dim_eq_dim_subalgebra : module.rank K F.to_subalgebra = module.rank K F := rfl @[simp] lemma finrank_eq_finrank_subalgebra : finrank K F.to_subalgebra = finrank K F := rfl variables {F} {E} @[simp] lemma to_subalgebra_eq_iff : F.to_subalgebra = E.to_subalgebra ↔ F = E := by { rw [set_like.ext_iff, set_like.ext'_iff, set.ext_iff], refl } lemma eq_of_le_of_finrank_le [finite_dimensional K L] (h_le : F ≤ E) (h_finrank : finrank K E ≤ finrank K F) : F = E := to_subalgebra_injective $ subalgebra.to_submodule_injective $ eq_of_le_of_finrank_le h_le h_finrank lemma eq_of_le_of_finrank_eq [finite_dimensional K L] (h_le : F ≤ E) (h_finrank : finrank K F = finrank K E) : F = E := eq_of_le_of_finrank_le h_le h_finrank.ge lemma eq_of_le_of_finrank_le' [finite_dimensional K L] (h_le : F ≤ E) (h_finrank : finrank F L ≤ finrank E L) : F = E := begin apply eq_of_le_of_finrank_le h_le, have h1 := finrank_mul_finrank K F L, have h2 := finrank_mul_finrank K E L, have h3 : 0 < finrank E L := finrank_pos, nlinarith, end lemma eq_of_le_of_finrank_eq' [finite_dimensional K L] (h_le : F ≤ E) (h_finrank : finrank F L = finrank E L) : F = E := eq_of_le_of_finrank_le' h_le h_finrank.le end finite_dimensional end intermediate_field /-- If `L/K` is algebraic, the `K`-subalgebras of `L` are all fields. -/ def subalgebra_equiv_intermediate_field (alg : algebra.is_algebraic K L) : subalgebra K L ≃o intermediate_field K L := { to_fun := λ S, S.to_intermediate_field (λ x hx, S.inv_mem_of_algebraic (alg (⟨x, hx⟩ : S))), inv_fun := λ S, S.to_subalgebra, left_inv := λ S, to_subalgebra_to_intermediate_field _ _, right_inv := λ S, to_intermediate_field_to_subalgebra _ _, map_rel_iff' := λ S S', iff.rfl } @[simp] lemma mem_subalgebra_equiv_intermediate_field (alg : algebra.is_algebraic K L) {S : subalgebra K L} {x : L} : x ∈ subalgebra_equiv_intermediate_field alg S ↔ x ∈ S := iff.rfl @[simp] lemma mem_subalgebra_equiv_intermediate_field_symm (alg : algebra.is_algebraic K L) {S : intermediate_field K L} {x : L} : x ∈ (subalgebra_equiv_intermediate_field alg).symm S ↔ x ∈ S := iff.rfl
// Copyright (C) 2020 T. Zachary Laine // // 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) // Warning! This file is autogenerated. #include <boost/text/collation_table.hpp> #include <boost/text/collate.hpp> #include <boost/text/data/all.hpp> #ifndef LIMIT_TESTING_FOR_CI #include <boost/text/save_load_table.hpp> #include <boost/filesystem.hpp> #endif #include <gtest/gtest.h> using namespace boost::text; auto const error = [](std::string const & s) { std::cout << s; }; auto const warning = [](std::string const & s) {}; collation_table make_save_load_table() { #ifdef LIMIT_TESTING_FOR_CI std::string const table_str(data::zh::zhuyin_collation_tailoring()); return tailored_collation_table( table_str, "zh::zhuyin_collation_tailoring()", error, warning); #else if (!exists(boost::filesystem::path("zh_zhuyin.table"))) { std::string const table_str(data::zh::zhuyin_collation_tailoring()); collation_table table = tailored_collation_table( table_str, "zh::zhuyin_collation_tailoring()", error, warning); save_table(table, "zh_zhuyin.table.19"); boost::filesystem::rename("zh_zhuyin.table.19", "zh_zhuyin.table"); } return load_table("zh_zhuyin.table"); #endif } collation_table const & table() { static collation_table retval = make_save_load_table(); return retval; } TEST(tailoring, zh_zhuyin_018_000) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x22cc6); auto const rel = std::vector<uint32_t>(1, 0x58ba); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58ba); auto const rel = std::vector<uint32_t>(1, 0x5db4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5db4); auto const rel = std::vector<uint32_t>(1, 0x61ca); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61ca); auto const rel = std::vector<uint32_t>(1, 0x64d9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64d9); auto const rel = std::vector<uint32_t>(1, 0x6fb3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6fb3); auto const rel = std::vector<uint32_t>(1, 0x96a9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x96a9); auto const rel = std::vector<uint32_t>(1, 0x93ca); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93ca); auto const rel = std::vector<uint32_t>(1, 0x9a41); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a41); auto const rel = std::vector<uint32_t>(1, 0x7ff6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ff6); auto const rel = std::vector<uint32_t>{0xfdd0, 0x3121}; std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>{0xfdd0, 0x3121}; auto const rel = std::vector<uint32_t>(1, 0x8bb4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8bb4); auto const rel = std::vector<uint32_t>(1, 0x6ca4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ca4); auto const rel = std::vector<uint32_t>(1, 0x6b27); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b27); auto const rel = std::vector<uint32_t>(1, 0x6bb4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bb4); auto const rel = std::vector<uint32_t>(1, 0x74ef); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74ef); auto const rel = std::vector<uint32_t>(1, 0x9e25); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e25); auto const rel = std::vector<uint32_t>(1, 0x5878); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5878); auto const rel = std::vector<uint32_t>(1, 0x6f1a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f1a); auto const rel = std::vector<uint32_t>(1, 0x6b50); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b50); auto const rel = std::vector<uint32_t>(1, 0x6bc6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bc6); auto const rel = std::vector<uint32_t>(1, 0x71b0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71b0); auto const rel = std::vector<uint32_t>(1, 0x9d0e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d0e); auto const rel = std::vector<uint32_t>(1, 0x750c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x750c); auto const rel = std::vector<uint32_t>(1, 0x210bf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x210bf); auto const rel = std::vector<uint32_t>(1, 0x8b33); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b33); auto const rel = std::vector<uint32_t>(1, 0x6ad9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ad9); auto const rel = std::vector<uint32_t>(1, 0x93c2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93c2); auto const rel = std::vector<uint32_t>(1, 0x9dd7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd7); auto const rel = std::vector<uint32_t>(1, 0x4972); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4972); auto const rel = std::vector<uint32_t>(1, 0x8192); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8192); auto const rel = std::vector<uint32_t>(1, 0x9f75); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f75); auto const rel = std::vector<uint32_t>(1, 0x20676); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x20676); auto const rel = std::vector<uint32_t>(1, 0x5418); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5418); auto const rel = std::vector<uint32_t>(1, 0x5455); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5455); auto const rel = std::vector<uint32_t>(1, 0x5076); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5076); auto const rel = std::vector<uint32_t>(1, 0x8162); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8162); auto const rel = std::vector<uint32_t>(1, 0x5614); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5614); auto const rel = std::vector<uint32_t>(1, 0x3496); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3496); auto const rel = std::vector<uint32_t>(1, 0x8026); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8026); auto const rel = std::vector<uint32_t>(1, 0x8545); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8545); auto const rel = std::vector<uint32_t>(1, 0x85d5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85d5); auto const rel = std::vector<uint32_t>(1, 0x6004); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6004); auto const rel = std::vector<uint32_t>(1, 0x616a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x616a); auto const rel = std::vector<uint32_t>(1, 0x85f2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85f2); auto const rel = std::vector<uint32_t>{0xfdd0, 0x3122}; std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>{0xfdd0, 0x3122}; auto const rel = std::vector<uint32_t>(1, 0x5b89); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b89); auto const rel = std::vector<uint32_t>(1, 0x4f92); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f92); auto const rel = std::vector<uint32_t>(1, 0x5cd6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cd6); auto const rel = std::vector<uint32_t>(1, 0x6849); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6849); auto const rel = std::vector<uint32_t>(1, 0x6c28); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c28); auto const rel = std::vector<uint32_t>(1, 0x5eb5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_001) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5eb5); auto const rel = std::vector<uint32_t>(1, 0x4002); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4002); auto const rel = std::vector<uint32_t>(1, 0x8c19); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c19); auto const rel = std::vector<uint32_t>(1, 0x5a95); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a95); auto const rel = std::vector<uint32_t>(1, 0x83f4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83f4); auto const rel = std::vector<uint32_t>(1, 0x75f7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75f7); auto const rel = std::vector<uint32_t>(1, 0x8164); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8164); auto const rel = std::vector<uint32_t>(1, 0x843b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x843b); auto const rel = std::vector<uint32_t>(1, 0x844a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x844a); auto const rel = std::vector<uint32_t>(1, 0x9e4c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e4c); auto const rel = std::vector<uint32_t>(1, 0x8a9d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a9d); auto const rel = std::vector<uint32_t>(1, 0x84ed); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x84ed); auto const rel = std::vector<uint32_t>(1, 0x978c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x978c); auto const rel = std::vector<uint32_t>(1, 0x978d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x978d); auto const rel = std::vector<uint32_t>(1, 0x76e6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76e6); auto const rel = std::vector<uint32_t>(1, 0x8af3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8af3); auto const rel = std::vector<uint32_t>(1, 0x99a3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99a3); auto const rel = std::vector<uint32_t>(1, 0x76eb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76eb); auto const rel = std::vector<uint32_t>(1, 0x9d6a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d6a); auto const rel = std::vector<uint32_t>(1, 0x97fd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97fd); auto const rel = std::vector<uint32_t>(1, 0x9d95); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d95); auto const rel = std::vector<uint32_t>(1, 0x73b5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x73b5); auto const rel = std::vector<uint32_t>(1, 0x557d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x557d); auto const rel = std::vector<uint32_t>(1, 0x96f8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x96f8); auto const rel = std::vector<uint32_t>(1, 0x5111); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5111); auto const rel = std::vector<uint32_t>(1, 0x57b5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57b5); auto const rel = std::vector<uint32_t>(1, 0x4ffa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ffa); auto const rel = std::vector<uint32_t>(1, 0x5535); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5535); auto const rel = std::vector<uint32_t>(1, 0x57ef); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57ef); auto const rel = std::vector<uint32_t>(1, 0x94f5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94f5); auto const rel = std::vector<uint32_t>(1, 0x63de); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63de); auto const rel = std::vector<uint32_t>(1, 0x968c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x968c); auto const rel = std::vector<uint32_t>(1, 0x7f6f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f6f); auto const rel = std::vector<uint32_t>(1, 0x92a8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92a8); auto const rel = std::vector<uint32_t>(1, 0x72b4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72b4); auto const rel = std::vector<uint32_t>(1, 0x5cb8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cb8); auto const rel = std::vector<uint32_t>(1, 0x6309); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6309); auto const rel = std::vector<uint32_t>(1, 0x6d1d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d1d); auto const rel = std::vector<uint32_t>(1, 0x6848); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6848); auto const rel = std::vector<uint32_t>(1, 0x80fa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80fa); auto const rel = std::vector<uint32_t>(1, 0x834c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x834c); auto const rel = std::vector<uint32_t>(1, 0x8c7b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c7b); auto const rel = std::vector<uint32_t>(1, 0x5813); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5813); auto const rel = std::vector<uint32_t>(1, 0x5a69); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a69); auto const rel = std::vector<uint32_t>(1, 0x4141); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4141); auto const rel = std::vector<uint32_t>(1, 0x667b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x667b); auto const rel = std::vector<uint32_t>(1, 0x6697); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6697); auto const rel = std::vector<uint32_t>(1, 0x930c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x930c); auto const rel = std::vector<uint32_t>(1, 0x95c7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95c7); auto const rel = std::vector<uint32_t>(1, 0x9b9f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b9f); auto const rel = std::vector<uint32_t>(1, 0x4b97); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4b97); auto const rel = std::vector<uint32_t>(1, 0x9eef); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_002) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eef); auto const rel = std::vector<uint32_t>{0xfdd0, 0x3123}; std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>{0xfdd0, 0x3123}; auto const rel = std::vector<uint32_t>(1, 0x5940); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5940); auto const rel = std::vector<uint32_t>(1, 0x6069); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6069); auto const rel = std::vector<uint32_t>(1, 0x217ef); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x217ef); auto const rel = std::vector<uint32_t>(1, 0x717e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x717e); auto const rel = std::vector<uint32_t>(1, 0x84bd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x84bd); auto const rel = std::vector<uint32_t>(1, 0x5cce); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cce); auto const rel = std::vector<uint32_t>(1, 0x6441); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6441); auto const rel = std::vector<uint32_t>(1, 0x4b53); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4b53); auto const rel = std::vector<uint32_t>{0xfdd0, 0x3124}; std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>{0xfdd0, 0x3124}; auto const rel = std::vector<uint32_t>(1, 0x80ae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80ae); auto const rel = std::vector<uint32_t>(1, 0x9aaf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9aaf); auto const rel = std::vector<uint32_t>(1, 0x536c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x536c); auto const rel = std::vector<uint32_t>(1, 0x5c87); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c87); auto const rel = std::vector<uint32_t>(1, 0x6602); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6602); auto const rel = std::vector<uint32_t>(1, 0x663b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x663b); auto const rel = std::vector<uint32_t>(1, 0x44a2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x44a2); auto const rel = std::vector<uint32_t>(1, 0x3b7f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3b7f); auto const rel = std::vector<uint32_t>(1, 0x678a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x678a); auto const rel = std::vector<uint32_t>(1, 0x76ce); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76ce); auto const rel = std::vector<uint32_t>(1, 0x91a0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91a0); auto const rel = std::vector<uint32_t>{0xfdd0, 0x3125}; std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>{0xfdd0, 0x3125}; auto const rel = std::vector<uint32_t>(1, 0x97a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x97a5); auto const rel = std::vector<uint32_t>{0xfdd0, 0x3126}; std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>{0xfdd0, 0x3126}; auto const rel = std::vector<uint32_t>(1, 0x513f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x513f); auto const rel = std::vector<uint32_t>(1, 0x800c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x800c); auto const rel = std::vector<uint32_t>(1, 0x5150); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5150); auto const rel = std::vector<uint32_t>(1, 0x4f95); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f95); auto const rel = std::vector<uint32_t>(1, 0x5152); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5152); auto const rel = std::vector<uint32_t>(1, 0x5ccf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ccf); auto const rel = std::vector<uint32_t>(1, 0x6d0f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d0f); auto const rel = std::vector<uint32_t>(1, 0x9651); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9651); auto const rel = std::vector<uint32_t>(1, 0x682d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x682d); auto const rel = std::vector<uint32_t>(1, 0x80f9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80f9); auto const rel = std::vector<uint32_t>(1, 0x834b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x834b); auto const rel = std::vector<uint32_t>(1, 0x5532); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5532); auto const rel = std::vector<uint32_t>(1, 0x9e38); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e38); auto const rel = std::vector<uint32_t>(1, 0x7cab); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cab); auto const rel = std::vector<uint32_t>(1, 0x804f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x804f); auto const rel = std::vector<uint32_t>(1, 0x88bb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x88bb); auto const rel = std::vector<uint32_t>(1, 0x8f00); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f00); auto const rel = std::vector<uint32_t>(1, 0x42e9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x42e9); auto const rel = std::vector<uint32_t>(1, 0x9c95); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c95); auto const rel = std::vector<uint32_t>(1, 0x9af5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9af5); auto const rel = std::vector<uint32_t>(1, 0x96ad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x96ad); auto const rel = std::vector<uint32_t>(1, 0x9b9e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b9e); auto const rel = std::vector<uint32_t>(1, 0x9d2f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d2f); auto const rel = std::vector<uint32_t>(1, 0x8f5c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f5c); auto const rel = std::vector<uint32_t>(1, 0x53bc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x53bc); auto const rel = std::vector<uint32_t>(1, 0x5c12); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c12); auto const rel = std::vector<uint32_t>(1, 0x5c13); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_003) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c13); auto const rel = std::vector<uint32_t>(1, 0x5c14); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c14); auto const rel = std::vector<uint32_t>(1, 0x8033); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8033); auto const rel = std::vector<uint32_t>(1, 0x6d31); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d31); auto const rel = std::vector<uint32_t>(1, 0x8fe9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8fe9); auto const rel = std::vector<uint32_t>(1, 0x9975); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9975); auto const rel = std::vector<uint32_t>(1, 0x682e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x682e); auto const rel = std::vector<uint32_t>(1, 0x6be6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6be6); auto const rel = std::vector<uint32_t>(1, 0x73e5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x73e5); auto const rel = std::vector<uint32_t>(1, 0x94d2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94d2); auto const rel = std::vector<uint32_t>(1, 0x723e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x723e); auto const rel = std::vector<uint32_t>(1, 0x990c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x990c); auto const rel = std::vector<uint32_t>(1, 0x99ec); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99ec); auto const rel = std::vector<uint32_t>(1, 0x85be); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85be); auto const rel = std::vector<uint32_t>(1, 0x9087); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9087); auto const rel = std::vector<uint32_t>(1, 0x8db0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8db0); auto const rel = std::vector<uint32_t>(1, 0x4e8c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e8c); auto const rel = std::vector<uint32_t>(1, 0x5f0d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f0d); auto const rel = std::vector<uint32_t>(1, 0x5f10); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f10); auto const rel = std::vector<uint32_t>(1, 0x4f74); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f74); auto const rel = std::vector<uint32_t>(1, 0x5235); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5235); auto const rel = std::vector<uint32_t>(1, 0x54a1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x54a1); auto const rel = std::vector<uint32_t>(1, 0x36c5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x36c5); auto const rel = std::vector<uint32_t>(1, 0x8d30); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d30); auto const rel = std::vector<uint32_t>(1, 0x8cae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8cae); auto const rel = std::vector<uint32_t>(1, 0x8848); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8848); auto const rel = std::vector<uint32_t>(1, 0x8cb3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8cb3); auto const rel = std::vector<uint32_t>(1, 0x8a80); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a80); auto const rel = std::vector<uint32_t>(1, 0x927a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x927a); auto const rel = std::vector<uint32_t>(1, 0x6a32); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a32); auto const rel = std::vector<uint32_t>{0xfdd0, 0x3127}; std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>{0xfdd0, 0x3127}; auto const rel = std::vector<uint32_t>(1, 0x4e00); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e00); auto const rel = std::vector<uint32_t>(1, 0x4e4a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e4a); auto const rel = std::vector<uint32_t>(1, 0x5f0c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f0c); auto const rel = std::vector<uint32_t>(1, 0x8864); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8864); auto const rel = std::vector<uint32_t>(1, 0x4f0a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f0a); auto const rel = std::vector<uint32_t>(1, 0x8863); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8863); auto const rel = std::vector<uint32_t>(1, 0x533b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x533b); auto const rel = std::vector<uint32_t>(1, 0x541a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x541a); auto const rel = std::vector<uint32_t>(1, 0x58f1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58f1); auto const rel = std::vector<uint32_t>(1, 0x4f9d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f9d); auto const rel = std::vector<uint32_t>(1, 0x54bf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x54bf); auto const rel = std::vector<uint32_t>(1, 0x20c96); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x20c96); auto const rel = std::vector<uint32_t>(1, 0x36c4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x36c4); auto const rel = std::vector<uint32_t>(1, 0x3cd6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3cd6); auto const rel = std::vector<uint32_t>(1, 0x6d22); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d22); auto const rel = std::vector<uint32_t>(1, 0x794e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x794e); auto const rel = std::vector<uint32_t>(1, 0x2343f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2343f); auto const rel = std::vector<uint32_t>(1, 0x6098); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6098); auto const rel = std::vector<uint32_t>(1, 0x7317); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7317); auto const rel = std::vector<uint32_t>(1, 0x94f1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94f1); auto const rel = std::vector<uint32_t>(1, 0x58f9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_004) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58f9); auto const rel = std::vector<uint32_t>(1, 0x63d6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63d6); auto const rel = std::vector<uint32_t>(1, 0x6b39); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b39); auto const rel = std::vector<uint32_t>(1, 0x86dc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x86dc); auto const rel = std::vector<uint32_t>(1, 0x90fc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x90fc); auto const rel = std::vector<uint32_t>(1, 0x5adb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5adb); auto const rel = std::vector<uint32_t>(1, 0x6f2a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f2a); auto const rel = std::vector<uint32_t>(1, 0x7995); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7995); auto const rel = std::vector<uint32_t>(1, 0x7a26); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a26); auto const rel = std::vector<uint32_t>(1, 0x92a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92a5); auto const rel = std::vector<uint32_t>(1, 0x5b04); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b04); auto const rel = std::vector<uint32_t>(1, 0x566b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x566b); auto const rel = std::vector<uint32_t>(1, 0x5901); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5901); auto const rel = std::vector<uint32_t>(1, 0x747f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x747f); auto const rel = std::vector<uint32_t>(1, 0x9e65); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e65); auto const rel = std::vector<uint32_t>(1, 0x7e44); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e44); auto const rel = std::vector<uint32_t>(1, 0x4ad1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ad1); auto const rel = std::vector<uint32_t>(1, 0x6ab9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ab9); auto const rel = std::vector<uint32_t>(1, 0x6bc9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bc9); auto const rel = std::vector<uint32_t>(1, 0x91ab); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91ab); auto const rel = std::vector<uint32_t>(1, 0x9edf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9edf); auto const rel = std::vector<uint32_t>(1, 0x8b69); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b69); auto const rel = std::vector<uint32_t>(1, 0x9dd6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd6); auto const rel = std::vector<uint32_t>(1, 0x9ef3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ef3); auto const rel = std::vector<uint32_t>(1, 0x4e41); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e41); auto const rel = std::vector<uint32_t>(1, 0x4eea); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4eea); auto const rel = std::vector<uint32_t>(1, 0x531c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x531c); auto const rel = std::vector<uint32_t>(1, 0x572f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x572f); auto const rel = std::vector<uint32_t>(1, 0x5937); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5937); auto const rel = std::vector<uint32_t>(1, 0x519d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x519d); auto const rel = std::vector<uint32_t>(1, 0x5b90); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b90); auto const rel = std::vector<uint32_t>(1, 0x6c82); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c82); auto const rel = std::vector<uint32_t>(1, 0x8bd2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8bd2); auto const rel = std::vector<uint32_t>(1, 0x8fc6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8fc6); auto const rel = std::vector<uint32_t>(1, 0x4f87); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f87); auto const rel = std::vector<uint32_t>(1, 0x5b9c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b9c); auto const rel = std::vector<uint32_t>(1, 0x6021); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6021); auto const rel = std::vector<uint32_t>(1, 0x6cb6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6cb6); auto const rel = std::vector<uint32_t>(1, 0x72cb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72cb); auto const rel = std::vector<uint32_t>(1, 0x9974); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9974); auto const rel = std::vector<uint32_t>(1, 0x54a6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x54a6); auto const rel = std::vector<uint32_t>(1, 0x59e8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x59e8); auto const rel = std::vector<uint32_t>(1, 0x5cd3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cd3); auto const rel = std::vector<uint32_t>(1, 0x5df8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5df8); auto const rel = std::vector<uint32_t>(1, 0x5f2c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f2c); auto const rel = std::vector<uint32_t>(1, 0x605e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x605e); auto const rel = std::vector<uint32_t>(1, 0x62f8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x62f8); auto const rel = std::vector<uint32_t>(1, 0x67c2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67c2); auto const rel = std::vector<uint32_t>(1, 0x73c6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x73c6); auto const rel = std::vector<uint32_t>(1, 0x886a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x886a); auto const rel = std::vector<uint32_t>(1, 0x8d3b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d3b); auto const rel = std::vector<uint32_t>(1, 0x8fe4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_005) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8fe4); auto const rel = std::vector<uint32_t>(1, 0x5ba7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ba7); auto const rel = std::vector<uint32_t>(1, 0x6245); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6245); auto const rel = std::vector<uint32_t>(1, 0x6818); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6818); auto const rel = std::vector<uint32_t>(1, 0x684b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x684b); auto const rel = std::vector<uint32_t>(1, 0x3ebf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3ebf); auto const rel = std::vector<uint32_t>(1, 0x74f5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x74f5); auto const rel = std::vector<uint32_t>(1, 0x7719); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7719); auto const rel = std::vector<uint32_t>(1, 0x80f0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80f0); auto const rel = std::vector<uint32_t>(1, 0x8a11); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a11); auto const rel = std::vector<uint32_t>(1, 0x8ca4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ca4); auto const rel = std::vector<uint32_t>(1, 0x8ffb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ffb); auto const rel = std::vector<uint32_t>(1, 0x75cd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75cd); auto const rel = std::vector<uint32_t>(1, 0x79fb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79fb); auto const rel = std::vector<uint32_t>(1, 0x801b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x801b); auto const rel = std::vector<uint32_t>(1, 0x8898); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8898); auto const rel = std::vector<uint32_t>(1, 0x51d2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x51d2); auto const rel = std::vector<uint32_t>(1, 0x7fa0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fa0); auto const rel = std::vector<uint32_t>(1, 0x8413); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8413); auto const rel = std::vector<uint32_t>(1, 0x86e6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x86e6); auto const rel = std::vector<uint32_t>(1, 0x8a51); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a51); auto const rel = std::vector<uint32_t>(1, 0x8a52); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a52); auto const rel = std::vector<uint32_t>(1, 0x8cbd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8cbd); auto const rel = std::vector<uint32_t>(1, 0x5a90); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a90); auto const rel = std::vector<uint32_t>(1, 0x6686); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6686); auto const rel = std::vector<uint32_t>(1, 0x6938); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6938); auto const rel = std::vector<uint32_t>(1, 0x8a83); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a83); auto const rel = std::vector<uint32_t>(1, 0x8de0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8de0); auto const rel = std::vector<uint32_t>(1, 0x9057); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9057); auto const rel = std::vector<uint32_t>(1, 0x9809); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9809); auto const rel = std::vector<uint32_t>(1, 0x9890); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9890); auto const rel = std::vector<uint32_t>(1, 0x98f4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98f4); auto const rel = std::vector<uint32_t>(1, 0x7591); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7591); auto const rel = std::vector<uint32_t>(1, 0x5100); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5100); auto const rel = std::vector<uint32_t>(1, 0x71aa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71aa); auto const rel = std::vector<uint32_t>(1, 0x7bb7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7bb7); auto const rel = std::vector<uint32_t>(1, 0x5dac); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dac); auto const rel = std::vector<uint32_t>(1, 0x5f5b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f5b); auto const rel = std::vector<uint32_t>(1, 0x5f5c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f5c); auto const rel = std::vector<uint32_t>(1, 0x8794); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8794); auto const rel = std::vector<uint32_t>(1, 0x907a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x907a); auto const rel = std::vector<uint32_t>(1, 0x9824); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9824); auto const rel = std::vector<uint32_t>(1, 0x5bf2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5bf2); auto const rel = std::vector<uint32_t>(1, 0x5db7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5db7); auto const rel = std::vector<uint32_t>(1, 0x7c03); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c03); auto const rel = std::vector<uint32_t>(1, 0x984a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x984a); auto const rel = std::vector<uint32_t>(1, 0x294e7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x294e7); auto const rel = std::vector<uint32_t>(1, 0x4c4c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4c4c); auto const rel = std::vector<uint32_t>(1, 0x5f5d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f5d); auto const rel = std::vector<uint32_t>(1, 0x5f5e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f5e); auto const rel = std::vector<uint32_t>(1, 0x8b3b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b3b); auto const rel = std::vector<uint32_t>(1, 0x93d4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_006) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93d4); auto const rel = std::vector<uint32_t>(1, 0x89fa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x89fa); auto const rel = std::vector<uint32_t>(1, 0x3c18); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3c18); auto const rel = std::vector<uint32_t>(1, 0x8b89); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b89); auto const rel = std::vector<uint32_t>(1, 0x9e03); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e03); auto const rel = std::vector<uint32_t>(1, 0x4e59); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e59); auto const rel = std::vector<uint32_t>(1, 0x5df2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5df2); auto const rel = std::vector<uint32_t>(1, 0x4ee5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ee5); auto const rel = std::vector<uint32_t>(1, 0x9487); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9487); auto const rel = std::vector<uint32_t>(1, 0x4f41); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f41); auto const rel = std::vector<uint32_t>(1, 0x20bcb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x20bcb); auto const rel = std::vector<uint32_t>(1, 0x653a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x653a); auto const rel = std::vector<uint32_t>(1, 0x77e3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77e3); auto const rel = std::vector<uint32_t>(1, 0x8094); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8094); auto const rel = std::vector<uint32_t>(1, 0x5ea1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ea1); auto const rel = std::vector<uint32_t>(1, 0x8223); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8223); auto const rel = std::vector<uint32_t>(1, 0x82e1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x82e1); auto const rel = std::vector<uint32_t>(1, 0x82e2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x82e2); auto const rel = std::vector<uint32_t>(1, 0x8681); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8681); auto const rel = std::vector<uint32_t>(1, 0x91d4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91d4); auto const rel = std::vector<uint32_t>(1, 0x501a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x501a); auto const rel = std::vector<uint32_t>(1, 0x6246); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6246); auto const rel = std::vector<uint32_t>(1, 0x914f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x914f); auto const rel = std::vector<uint32_t>(1, 0x506f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x506f); auto const rel = std::vector<uint32_t>(1, 0x7b16); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7b16); auto const rel = std::vector<uint32_t>(1, 0x9018); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9018); auto const rel = std::vector<uint32_t>(1, 0x5d3a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d3a); auto const rel = std::vector<uint32_t>(1, 0x65d1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65d1); auto const rel = std::vector<uint32_t>(1, 0x6905); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6905); auto const rel = std::vector<uint32_t>(1, 0x9ce6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ce6); auto const rel = std::vector<uint32_t>(1, 0x926f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x926f); auto const rel = std::vector<uint32_t>(1, 0x65d6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65d6); auto const rel = std::vector<uint32_t>(1, 0x88ff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x88ff); auto const rel = std::vector<uint32_t>(1, 0x8e26); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8e26); auto const rel = std::vector<uint32_t>(1, 0x8f22); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f22); auto const rel = std::vector<uint32_t>(1, 0x657c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x657c); auto const rel = std::vector<uint32_t>(1, 0x8798); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8798); auto const rel = std::vector<uint32_t>(1, 0x49e7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x49e7); auto const rel = std::vector<uint32_t>(1, 0x6aa5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6aa5); auto const rel = std::vector<uint32_t>(1, 0x4b72); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4b72); auto const rel = std::vector<uint32_t>(1, 0x7912); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7912); auto const rel = std::vector<uint32_t>(1, 0x8264); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8264); auto const rel = std::vector<uint32_t>(1, 0x87fb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x87fb); auto const rel = std::vector<uint32_t>(1, 0x9857); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9857); auto const rel = std::vector<uint32_t>(1, 0x8f59); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f59); auto const rel = std::vector<uint32_t>(1, 0x9f6e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f6e); auto const rel = std::vector<uint32_t>(1, 0x4e42); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e42); auto const rel = std::vector<uint32_t>(1, 0x20086); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x20086); auto const rel = std::vector<uint32_t>(1, 0x4e49); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e49); auto const rel = std::vector<uint32_t>(1, 0x4ebf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ebf); auto const rel = std::vector<uint32_t>(1, 0x5f0b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f0b); auto const rel = std::vector<uint32_t>(1, 0x5208); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_007) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5208); auto const rel = std::vector<uint32_t>(1, 0x5fc6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fc6); auto const rel = std::vector<uint32_t>(1, 0x808a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x808a); auto const rel = std::vector<uint32_t>(1, 0x827a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x827a); auto const rel = std::vector<uint32_t>(1, 0x8bae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8bae); auto const rel = std::vector<uint32_t>(1, 0x4ea6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ea6); auto const rel = std::vector<uint32_t>(1, 0x3439); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3439); auto const rel = std::vector<uint32_t>(1, 0x4f07); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f07); auto const rel = std::vector<uint32_t>(1, 0x5c79); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c79); auto const rel = std::vector<uint32_t>(1, 0x5f02); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f02); auto const rel = std::vector<uint32_t>(1, 0x4f3f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f3f); auto const rel = std::vector<uint32_t>(1, 0x4f5a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f5a); auto const rel = std::vector<uint32_t>(1, 0x52ae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x52ae); auto const rel = std::vector<uint32_t>(1, 0x5453); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5453); auto const rel = std::vector<uint32_t>(1, 0x5744); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5744); auto const rel = std::vector<uint32_t>(1, 0x5f79); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f79); auto const rel = std::vector<uint32_t>(1, 0x6291); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6291); auto const rel = std::vector<uint32_t>(1, 0x6759); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6759); auto const rel = std::vector<uint32_t>(1, 0x8034); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8034); auto const rel = std::vector<uint32_t>(1, 0x8285); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8285); auto const rel = std::vector<uint32_t>(1, 0x8bd1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8bd1); auto const rel = std::vector<uint32_t>(1, 0x9091); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9091); auto const rel = std::vector<uint32_t>(1, 0x4f7e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f7e); auto const rel = std::vector<uint32_t>(1, 0x546d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x546d); auto const rel = std::vector<uint32_t>(1, 0x5479); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5479); auto const rel = std::vector<uint32_t>(1, 0x5cc4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cc4); auto const rel = std::vector<uint32_t>(1, 0x6008); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6008); auto const rel = std::vector<uint32_t>(1, 0x603f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x603f); auto const rel = std::vector<uint32_t>(1, 0x6613); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6613); auto const rel = std::vector<uint32_t>(1, 0x678d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x678d); auto const rel = std::vector<uint32_t>(1, 0x6b25); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b25); auto const rel = std::vector<uint32_t>(1, 0x3cd1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3cd1); auto const rel = std::vector<uint32_t>(1, 0x6cc6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6cc6); auto const rel = std::vector<uint32_t>(1, 0x7088); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7088); auto const rel = std::vector<uint32_t>(1, 0x79c7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79c7); auto const rel = std::vector<uint32_t>(1, 0x7ece); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ece); auto const rel = std::vector<uint32_t>(1, 0x82c5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x82c5); auto const rel = std::vector<uint32_t>(1, 0x8be3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8be3); auto const rel = std::vector<uint32_t>(1, 0x9a7f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a7f); auto const rel = std::vector<uint32_t>(1, 0x4fcb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4fcb); auto const rel = std::vector<uint32_t>(1, 0x5955); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5955); auto const rel = std::vector<uint32_t>(1, 0x5e1f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e1f); auto const rel = std::vector<uint32_t>(1, 0x5e20); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e20); auto const rel = std::vector<uint32_t>(1, 0x5f08); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5f08); auto const rel = std::vector<uint32_t>(1, 0x223d7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x223d7); auto const rel = std::vector<uint32_t>(1, 0x67bb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67bb); auto const rel = std::vector<uint32_t>(1, 0x6d02); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d02); auto const rel = std::vector<uint32_t>(1, 0x6d42); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d42); auto const rel = std::vector<uint32_t>(1, 0x73b4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x73b4); auto const rel = std::vector<uint32_t>(1, 0x75ab); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75ab); auto const rel = std::vector<uint32_t>(1, 0x7fbf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fbf); auto const rel = std::vector<uint32_t>(1, 0x263f8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_008) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x263f8); auto const rel = std::vector<uint32_t>(1, 0x8f76); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f76); auto const rel = std::vector<uint32_t>(1, 0x3465); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3465); auto const rel = std::vector<uint32_t>(1, 0x5508); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5508); auto const rel = std::vector<uint32_t>(1, 0x57bc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57bc); auto const rel = std::vector<uint32_t>(1, 0x6092); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6092); auto const rel = std::vector<uint32_t>(1, 0x6339); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6339); auto const rel = std::vector<uint32_t>(1, 0x6359); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6359); auto const rel = std::vector<uint32_t>(1, 0x6827); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6827); auto const rel = std::vector<uint32_t>(1, 0x683a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x683a); auto const rel = std::vector<uint32_t>(1, 0x6b2d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b2d); auto const rel = std::vector<uint32_t>(1, 0x6d65); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d65); auto const rel = std::vector<uint32_t>(1, 0x6d73); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d73); auto const rel = std::vector<uint32_t>(1, 0x76ca); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76ca); auto const rel = std::vector<uint32_t>(1, 0x8875); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8875); auto const rel = std::vector<uint32_t>(1, 0x8c0a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c0a); auto const rel = std::vector<uint32_t>(1, 0x52da); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x52da); auto const rel = std::vector<uint32_t>(1, 0x57f6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57f6); auto const rel = std::vector<uint32_t>(1, 0x57f8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57f8); auto const rel = std::vector<uint32_t>(1, 0x60a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x60a5); auto const rel = std::vector<uint32_t>(1, 0x639c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x639c); auto const rel = std::vector<uint32_t>(1, 0x6bb9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bb9); auto const rel = std::vector<uint32_t>(1, 0x7570); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7570); auto const rel = std::vector<uint32_t>(1, 0x785b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x785b); auto const rel = std::vector<uint32_t>(1, 0x7f9b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f9b); auto const rel = std::vector<uint32_t>(1, 0x7fca); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fca); auto const rel = std::vector<uint32_t>(1, 0x7fcc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fcc); auto const rel = std::vector<uint32_t>(1, 0x88a3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x88a3); auto const rel = std::vector<uint32_t>(1, 0x8a32); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a32); auto const rel = std::vector<uint32_t>(1, 0x8a33); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a33); auto const rel = std::vector<uint32_t>(1, 0x8c59); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c59); auto const rel = std::vector<uint32_t>(1, 0x8c5b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c5b); auto const rel = std::vector<uint32_t>(1, 0x91f4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91f4); auto const rel = std::vector<uint32_t>(1, 0x966d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x966d); auto const rel = std::vector<uint32_t>(1, 0x96bf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x96bf); auto const rel = std::vector<uint32_t>(1, 0x5e46); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e46); auto const rel = std::vector<uint32_t>(1, 0x6561); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6561); auto const rel = std::vector<uint32_t>(1, 0x6679); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6679); auto const rel = std::vector<uint32_t>(1, 0x68ed); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x68ed); auto const rel = std::vector<uint32_t>(1, 0x6b94); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b94); auto const rel = std::vector<uint32_t>(1, 0x6e59); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e59); auto const rel = std::vector<uint32_t>(1, 0x7132); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7132); auto const rel = std::vector<uint32_t>(1, 0x2497f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2497f); auto const rel = std::vector<uint32_t>(1, 0x433b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x433b); auto const rel = std::vector<uint32_t>(1, 0x86e1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x86e1); auto const rel = std::vector<uint32_t>(1, 0x8a4d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a4d); auto const rel = std::vector<uint32_t>(1, 0x8dc7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8dc7); auto const rel = std::vector<uint32_t>(1, 0x8efc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8efc); auto const rel = std::vector<uint32_t>(1, 0x9038); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9038); auto const rel = std::vector<uint32_t>(1, 0x9220); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9220); auto const rel = std::vector<uint32_t>(1, 0x4e84); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e84); auto const rel = std::vector<uint32_t>(1, 0x517f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_009) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x517f); auto const rel = std::vector<uint32_t>(1, 0x3534); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3534); auto const rel = std::vector<uint32_t>(1, 0x610f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x610f); auto const rel = std::vector<uint32_t>(1, 0x6ea2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6ea2); auto const rel = std::vector<uint32_t>(1, 0x7348); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7348); auto const rel = std::vector<uint32_t>(1, 0x75ec); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75ec); auto const rel = std::vector<uint32_t>(1, 0x776a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x776a); auto const rel = std::vector<uint32_t>(1, 0x7ae9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ae9); auto const rel = std::vector<uint32_t>(1, 0x41fc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x41fc); auto const rel = std::vector<uint32_t>(1, 0x7f22); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f22); auto const rel = std::vector<uint32_t>(1, 0x7fa9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7fa9); auto const rel = std::vector<uint32_t>(1, 0x8084); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8084); auto const rel = std::vector<uint32_t>(1, 0x88d4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x88d4); auto const rel = std::vector<uint32_t>(1, 0x88db); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x88db); auto const rel = std::vector<uint32_t>(1, 0x8a63); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a63); auto const rel = std::vector<uint32_t>(1, 0x9aae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9aae); auto const rel = std::vector<uint32_t>(1, 0x52e9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x52e9); auto const rel = std::vector<uint32_t>(1, 0x5ad5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ad5); auto const rel = std::vector<uint32_t>(1, 0x5ed9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ed9); auto const rel = std::vector<uint32_t>(1, 0x698f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x698f); auto const rel = std::vector<uint32_t>(1, 0x7617); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7617); auto const rel = std::vector<uint32_t>(1, 0x8189); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8189); auto const rel = std::vector<uint32_t>(1, 0x8734); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8734); auto const rel = std::vector<uint32_t>(1, 0x977e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x977e); auto const rel = std::vector<uint32_t>(1, 0x99c5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99c5); auto const rel = std::vector<uint32_t>(1, 0x5104); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5104); auto const rel = std::vector<uint32_t>(1, 0x3989); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3989); auto const rel = std::vector<uint32_t>(1, 0x648e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x648e); auto const rel = std::vector<uint32_t>(1, 0x69f8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x69f8); auto const rel = std::vector<uint32_t>(1, 0x6bc5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6bc5); auto const rel = std::vector<uint32_t>(1, 0x6f69); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f69); auto const rel = std::vector<uint32_t>(1, 0x71a0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71a0); auto const rel = std::vector<uint32_t>(1, 0x71a4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71a4); auto const rel = std::vector<uint32_t>(1, 0x761e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x761e); auto const rel = std::vector<uint32_t>(1, 0x84fa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x84fa); auto const rel = std::vector<uint32_t>(1, 0x8abc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8abc); auto const rel = std::vector<uint32_t>(1, 0x9552); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9552); auto const rel = std::vector<uint32_t>(1, 0x9e5d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e5d); auto const rel = std::vector<uint32_t>(1, 0x9e62); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e62); auto const rel = std::vector<uint32_t>(1, 0x9ed3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ed3); auto const rel = std::vector<uint32_t>(1, 0x5293); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5293); auto const rel = std::vector<uint32_t>(1, 0x3601); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3601); auto const rel = std::vector<uint32_t>(1, 0x571b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x571b); auto const rel = std::vector<uint32_t>(1, 0x58bf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58bf); auto const rel = std::vector<uint32_t>(1, 0x5b11); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b11); auto const rel = std::vector<uint32_t>(1, 0x5b1f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b1f); auto const rel = std::vector<uint32_t>(1, 0x5da7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5da7); auto const rel = std::vector<uint32_t>(1, 0x61b6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61b6); auto const rel = std::vector<uint32_t>(1, 0x61cc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61cc); auto const rel = std::vector<uint32_t>(1, 0x66c0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66c0); auto const rel = std::vector<uint32_t>(1, 0x6baa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6baa); auto const rel = std::vector<uint32_t>(1, 0x3d69); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_010) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3d69); auto const rel = std::vector<uint32_t>(1, 0x6fba); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6fba); auto const rel = std::vector<uint32_t>(1, 0x71bc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71bc); auto const rel = std::vector<uint32_t>(1, 0x71da); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71da); auto const rel = std::vector<uint32_t>(1, 0x7631); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7631); auto const rel = std::vector<uint32_t>(1, 0x7796); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7796); auto const rel = std::vector<uint32_t>(1, 0x7a53); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a53); auto const rel = std::vector<uint32_t>(1, 0x7e0a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e0a); auto const rel = std::vector<uint32_t>(1, 0x8257); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8257); auto const rel = std::vector<uint32_t>(1, 0x87a0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x87a0); auto const rel = std::vector<uint32_t>(1, 0x5bf1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5bf1); auto const rel = std::vector<uint32_t>(1, 0x6581); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6581); auto const rel = std::vector<uint32_t>(1, 0x66ce); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66ce); auto const rel = std::vector<uint32_t>(1, 0x6a8d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6a8d); auto const rel = std::vector<uint32_t>(1, 0x6b5d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b5d); auto const rel = std::vector<uint32_t>(1, 0x71e1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71e1); auto const rel = std::vector<uint32_t>(1, 0x71f1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71f1); auto const rel = std::vector<uint32_t>(1, 0x7ff3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ff3); auto const rel = std::vector<uint32_t>(1, 0x7ffc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ffc); auto const rel = std::vector<uint32_t>(1, 0x81c6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81c6); auto const rel = std::vector<uint32_t>(1, 0x858f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x858f); auto const rel = std::vector<uint32_t>(1, 0x8939); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8939); auto const rel = std::vector<uint32_t>(1, 0x8cf9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8cf9); auto const rel = std::vector<uint32_t>(1, 0x9ba8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9ba8); auto const rel = std::vector<uint32_t>(1, 0x7654); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7654); auto const rel = std::vector<uint32_t>(1, 0x8d00); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8d00); auto const rel = std::vector<uint32_t>(1, 0x93b0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x93b0); auto const rel = std::vector<uint32_t>(1, 0x9571); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9571); auto const rel = std::vector<uint32_t>(1, 0x7e76); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e76); auto const rel = std::vector<uint32_t>(1, 0x7e79); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e79); auto const rel = std::vector<uint32_t>(1, 0x85d9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85d9); auto const rel = std::vector<uint32_t>(1, 0x85dd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85dd); auto const rel = std::vector<uint32_t>(1, 0x8c77); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c77); auto const rel = std::vector<uint32_t>(1, 0x972c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x972c); auto const rel = std::vector<uint32_t>(1, 0x9be3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9be3); auto const rel = std::vector<uint32_t>(1, 0x9d82); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d82); auto const rel = std::vector<uint32_t>(1, 0x9d83); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d83); auto const rel = std::vector<uint32_t>(1, 0x39a4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x39a4); auto const rel = std::vector<uint32_t>(1, 0x7037); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7037); auto const rel = std::vector<uint32_t>(1, 0x8b6f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b6f); auto const rel = std::vector<uint32_t>(1, 0x8b70); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b70); auto const rel = std::vector<uint32_t>(1, 0x91b3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b3); auto const rel = std::vector<uint32_t>(1, 0x91b7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91b7); auto const rel = std::vector<uint32_t>(1, 0x9950); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9950); auto const rel = std::vector<uint32_t>(1, 0x2113b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2113b); auto const rel = std::vector<uint32_t>(1, 0x25725); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x25725); auto const rel = std::vector<uint32_t>(1, 0x8619); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8619); auto const rel = std::vector<uint32_t>(1, 0x943f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x943f); auto const rel = std::vector<uint32_t>(1, 0x9dc1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc1); auto const rel = std::vector<uint32_t>(1, 0x9dca); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dca); auto const rel = std::vector<uint32_t>(1, 0x56c8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56c8); auto const rel = std::vector<uint32_t>(1, 0x61ff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_011) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61ff); auto const rel = std::vector<uint32_t>(1, 0x9a5b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a5b); auto const rel = std::vector<uint32_t>(1, 0x9de7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9de7); auto const rel = std::vector<uint32_t>(1, 0x9dfe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dfe); auto const rel = std::vector<uint32_t>(1, 0x8649); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8649); auto const rel = std::vector<uint32_t>(1, 0x897c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x897c); auto const rel = std::vector<uint32_t>(1, 0x9f78); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f78); auto const rel = std::vector<uint32_t>(1, 0x8b9b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b9b); auto const rel = std::vector<uint32_t>(1, 0x5307); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5307); auto const rel = std::vector<uint32_t>(1, 0x8fb7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8fb7); auto const rel = std::vector<uint32_t>(1, 0x7569); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7569); auto const rel = std::vector<uint32_t>(1, 0x692c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x692c); auto const rel = std::vector<uint32_t>(1, 0x841f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x841f); auto const rel = std::vector<uint32_t>(1, 0x9d8d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d8d); auto const rel = std::vector<uint32_t>(1, 0x7c4e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7c4e); auto const rel = std::vector<uint32_t>(1, 0x4e2b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e2b); auto const rel = std::vector<uint32_t>(1, 0x5727); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5727); auto const rel = std::vector<uint32_t>(1, 0x538b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x538b); auto const rel = std::vector<uint32_t>(1, 0x5416); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5416); auto const rel = std::vector<uint32_t>(1, 0x5e98); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e98); auto const rel = std::vector<uint32_t>(1, 0x62bc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x62bc); auto const rel = std::vector<uint32_t>(1, 0x6792); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6792); auto const rel = std::vector<uint32_t>(1, 0x57ad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57ad); auto const rel = std::vector<uint32_t>(1, 0x9e26); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e26); auto const rel = std::vector<uint32_t>(1, 0x6860); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6860); auto const rel = std::vector<uint32_t>(1, 0x9e2d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e2d); auto const rel = std::vector<uint32_t>(1, 0x57e1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57e1); auto const rel = std::vector<uint32_t>(1, 0x5b72); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b72); auto const rel = std::vector<uint32_t>(1, 0x690f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x690f); auto const rel = std::vector<uint32_t>(1, 0x9d09); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d09); auto const rel = std::vector<uint32_t>(1, 0x930f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x930f); auto const rel = std::vector<uint32_t>(1, 0x9d28); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d28); auto const rel = std::vector<uint32_t>(1, 0x58d3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58d3); auto const rel = std::vector<uint32_t>(1, 0x9d76); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d76); auto const rel = std::vector<uint32_t>(1, 0x941a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x941a); auto const rel = std::vector<uint32_t>(1, 0x7259); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7259); auto const rel = std::vector<uint32_t>(1, 0x4f22); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f22); auto const rel = std::vector<uint32_t>(1, 0x5391); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5391); auto const rel = std::vector<uint32_t>(1, 0x5c88); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c88); auto const rel = std::vector<uint32_t>(1, 0x5393); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5393); auto const rel = std::vector<uint32_t>(1, 0x73a1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x73a1); auto const rel = std::vector<uint32_t>(1, 0x82bd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x82bd); auto const rel = std::vector<uint32_t>(1, 0x7b0c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7b0c); auto const rel = std::vector<uint32_t>(1, 0x869c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x869c); auto const rel = std::vector<uint32_t>(1, 0x5810); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5810); auto const rel = std::vector<uint32_t>(1, 0x5d15); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d15); auto const rel = std::vector<uint32_t>(1, 0x5d16); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d16); auto const rel = std::vector<uint32_t>(1, 0x6daf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6daf); auto const rel = std::vector<uint32_t>(1, 0x731a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x731a); auto const rel = std::vector<uint32_t>(1, 0x740a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x740a); auto const rel = std::vector<uint32_t>(1, 0x7458); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7458); auto const rel = std::vector<uint32_t>(1, 0x775a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_012) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x775a); auto const rel = std::vector<uint32_t>(1, 0x8859); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8859); auto const rel = std::vector<uint32_t>(1, 0x6f04); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f04); auto const rel = std::vector<uint32_t>(1, 0x9f56); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f56); auto const rel = std::vector<uint32_t>(1, 0x2a632); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2a632); auto const rel = std::vector<uint32_t>(1, 0x24d13); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x24d13); auto const rel = std::vector<uint32_t>(1, 0x538a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x538a); auto const rel = std::vector<uint32_t>(1, 0x5e8c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e8c); auto const rel = std::vector<uint32_t>(1, 0x54d1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x54d1); auto const rel = std::vector<uint32_t>(1, 0x5516); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5516); auto const rel = std::vector<uint32_t>(1, 0x555e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x555e); auto const rel = std::vector<uint32_t>(1, 0x75d6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75d6); auto const rel = std::vector<uint32_t>(1, 0x96c5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x96c5); auto const rel = std::vector<uint32_t>(1, 0x7602); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7602); auto const rel = std::vector<uint32_t>(1, 0x279dd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x279dd); auto const rel = std::vector<uint32_t>(1, 0x8565); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8565); auto const rel = std::vector<uint32_t>(1, 0x529c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x529c); auto const rel = std::vector<uint32_t>(1, 0x5720); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5720); auto const rel = std::vector<uint32_t>(1, 0x8f67); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f67); auto const rel = std::vector<uint32_t>(1, 0x4e9a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e9a); auto const rel = std::vector<uint32_t>(1, 0x897e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x897e); auto const rel = std::vector<uint32_t>(1, 0x8bb6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8bb6); auto const rel = std::vector<uint32_t>(1, 0x4e9c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e9c); auto const rel = std::vector<uint32_t>(1, 0x72bd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72bd); auto const rel = std::vector<uint32_t>(1, 0x4e9e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e9e); auto const rel = std::vector<uint32_t>(1, 0x8ecb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ecb); auto const rel = std::vector<uint32_t>(1, 0x8fd3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8fd3); auto const rel = std::vector<uint32_t>(1, 0x5a05); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a05); auto const rel = std::vector<uint32_t>(1, 0x631c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x631c); auto const rel = std::vector<uint32_t>(1, 0x7811); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7811); auto const rel = std::vector<uint32_t>(1, 0x4ff9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ff9); auto const rel = std::vector<uint32_t>(1, 0x6c29); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c29); auto const rel = std::vector<uint32_t>(1, 0x5a6d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a6d); auto const rel = std::vector<uint32_t>(1, 0x6397); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6397); auto const rel = std::vector<uint32_t>(1, 0x8a1d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a1d); auto const rel = std::vector<uint32_t>(1, 0x94d4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94d4); auto const rel = std::vector<uint32_t>(1, 0x63e0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63e0); auto const rel = std::vector<uint32_t>(1, 0x6c2c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c2c); auto const rel = std::vector<uint32_t>(1, 0x7330); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7330); auto const rel = std::vector<uint32_t>(1, 0x8050); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8050); auto const rel = std::vector<uint32_t>(1, 0x26716); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x26716); auto const rel = std::vector<uint32_t>(1, 0x5714); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5714); auto const rel = std::vector<uint32_t>(1, 0x7a0f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a0f); auto const rel = std::vector<uint32_t>(1, 0x7aab); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7aab); auto const rel = std::vector<uint32_t>(1, 0x9f7e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f7e); auto const rel = std::vector<uint32_t>(1, 0x2e84); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2e84); auto const rel = std::vector<uint32_t>(1, 0x4e5b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e5b); auto const rel = std::vector<uint32_t>(1, 0x5440); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5440); auto const rel = std::vector<uint32_t>(1, 0x54df); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x54df); auto const rel = std::vector<uint32_t>(1, 0x5537); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5537); auto const rel = std::vector<uint32_t>(1, 0x55b2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x55b2); auto const rel = std::vector<uint32_t>(1, 0x503b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_013) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x503b); auto const rel = std::vector<uint32_t>(1, 0x6396); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6396); auto const rel = std::vector<uint32_t>(1, 0x668d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x668d); auto const rel = std::vector<uint32_t>(1, 0x6930); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6930); auto const rel = std::vector<uint32_t>(1, 0x564e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x564e); auto const rel = std::vector<uint32_t>(1, 0x6f71); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f71); auto const rel = std::vector<uint32_t>(1, 0x882e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x882e); auto const rel = std::vector<uint32_t>(1, 0x7237); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7237); auto const rel = std::vector<uint32_t>(1, 0x8036); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8036); auto const rel = std::vector<uint32_t>(1, 0x6353); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6353); auto const rel = std::vector<uint32_t>(1, 0x94d8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94d8); auto const rel = std::vector<uint32_t>(1, 0x63f6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63f6); auto const rel = std::vector<uint32_t>(1, 0x91fe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91fe); auto const rel = std::vector<uint32_t>(1, 0x723a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x723a); auto const rel = std::vector<uint32_t>(1, 0x92e3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92e3); auto const rel = std::vector<uint32_t>(1, 0x64e8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64e8); auto const rel = std::vector<uint32_t>(1, 0x9381); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9381); auto const rel = std::vector<uint32_t>(1, 0x4e5f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e5f); auto const rel = std::vector<uint32_t>(1, 0x5414); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5414); auto const rel = std::vector<uint32_t>(1, 0x51b6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x51b6); auto const rel = std::vector<uint32_t>(1, 0x57dc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x57dc); auto const rel = std::vector<uint32_t>(1, 0x91ce); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91ce); auto const rel = std::vector<uint32_t>(1, 0x5622); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5622); auto const rel = std::vector<uint32_t>(1, 0x6f1c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f1c); auto const rel = std::vector<uint32_t>(1, 0x58c4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58c4); auto const rel = std::vector<uint32_t>(1, 0x4e1a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e1a); auto const rel = std::vector<uint32_t>(1, 0x53f6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x53f6); auto const rel = std::vector<uint32_t>(1, 0x66f3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66f3); auto const rel = std::vector<uint32_t>(1, 0x9875); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9875); auto const rel = std::vector<uint32_t>(1, 0x66f5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66f5); auto const rel = std::vector<uint32_t>(1, 0x591c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x591c); auto const rel = std::vector<uint32_t>(1, 0x62b4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x62b4); auto const rel = std::vector<uint32_t>(1, 0x90ba); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x90ba); auto const rel = std::vector<uint32_t>(1, 0x4eb1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4eb1); auto const rel = std::vector<uint32_t>(1, 0x67bc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67bc); auto const rel = std::vector<uint32_t>(1, 0x9801); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9801); auto const rel = std::vector<uint32_t>(1, 0x6654); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6654); auto const rel = std::vector<uint32_t>(1, 0x67bd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67bd); auto const rel = std::vector<uint32_t>(1, 0x70e8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70e8); auto const rel = std::vector<uint32_t>(1, 0x35a1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x35a1); auto const rel = std::vector<uint32_t>(1, 0x5558); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5558); auto const rel = std::vector<uint32_t>(1, 0x6db2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6db2); auto const rel = std::vector<uint32_t>(1, 0x8c12); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c12); auto const rel = std::vector<uint32_t>(1, 0x5828); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5828); auto const rel = std::vector<uint32_t>(1, 0x6b97); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b97); auto const rel = std::vector<uint32_t>(1, 0x814b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x814b); auto const rel = std::vector<uint32_t>(1, 0x696a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x696a); auto const rel = std::vector<uint32_t>(1, 0x696d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x696d); auto const rel = std::vector<uint32_t>(1, 0x8449); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8449); auto const rel = std::vector<uint32_t>(1, 0x9113); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9113); auto const rel = std::vector<uint32_t>(1, 0x998c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x998c); auto const rel = std::vector<uint32_t>(1, 0x50f7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_014) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x50f7); auto const rel = std::vector<uint32_t>(1, 0x6b4b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b4b); auto const rel = std::vector<uint32_t>(1, 0x58b7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x58b7); auto const rel = std::vector<uint32_t>(1, 0x420e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x420e); auto const rel = std::vector<uint32_t>(1, 0x9765); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9765); auto const rel = std::vector<uint32_t>(1, 0x5daa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5daa); auto const rel = std::vector<uint32_t>(1, 0x5dab); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5dab); auto const rel = std::vector<uint32_t>(1, 0x64db); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64db); auto const rel = std::vector<uint32_t>(1, 0x66c4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66c4); auto const rel = std::vector<uint32_t>(1, 0x66c5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66c5); auto const rel = std::vector<uint32_t>(1, 0x6fb2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6fb2); auto const rel = std::vector<uint32_t>(1, 0x71c1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71c1); auto const rel = std::vector<uint32_t>(1, 0x2681c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2681c); auto const rel = std::vector<uint32_t>(1, 0x8b01); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b01); auto const rel = std::vector<uint32_t>(1, 0x9134); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9134); auto const rel = std::vector<uint32_t>(1, 0x9923); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9923); auto const rel = std::vector<uint32_t>(1, 0x5688); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5688); auto const rel = std::vector<uint32_t>(1, 0x64eb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64eb); auto const rel = std::vector<uint32_t>(1, 0x66d7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66d7); auto const rel = std::vector<uint32_t>(1, 0x76a3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x76a3); auto const rel = std::vector<uint32_t>(1, 0x77b1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77b1); auto const rel = std::vector<uint32_t>(1, 0x9371); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9371); auto const rel = std::vector<uint32_t>(1, 0x64ea); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x64ea); auto const rel = std::vector<uint32_t>(1, 0x77b8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77b8); auto const rel = std::vector<uint32_t>(1, 0x790f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x790f); auto const rel = std::vector<uint32_t>(1, 0x42a6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x42a6); auto const rel = std::vector<uint32_t>(1, 0x9391); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9391); auto const rel = std::vector<uint32_t>(1, 0x9941); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9941); auto const rel = std::vector<uint32_t>(1, 0x9d7a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d7a); auto const rel = std::vector<uint32_t>(1, 0x7217); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7217); auto const rel = std::vector<uint32_t>(1, 0x9437); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9437); auto const rel = std::vector<uint32_t>(1, 0x9768); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9768); auto const rel = std::vector<uint32_t>(1, 0x9a5c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a5c); auto const rel = std::vector<uint32_t>(1, 0x9e08); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e08); auto const rel = std::vector<uint32_t>(1, 0x4eaa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4eaa); auto const rel = std::vector<uint32_t>(1, 0x5e7a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e7a); auto const rel = std::vector<uint32_t>(1, 0x592d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x592d); auto const rel = std::vector<uint32_t>(1, 0x5406); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5406); auto const rel = std::vector<uint32_t>(1, 0x5996); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5996); auto const rel = std::vector<uint32_t>(1, 0x6796); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6796); auto const rel = std::vector<uint32_t>(1, 0x6b80); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6b80); auto const rel = std::vector<uint32_t>(1, 0x7945); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7945); auto const rel = std::vector<uint32_t>(1, 0x8a1e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a1e); auto const rel = std::vector<uint32_t>(1, 0x5593); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5593); auto const rel = std::vector<uint32_t>(1, 0x6946); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6946); auto const rel = std::vector<uint32_t>(1, 0x8170); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8170); auto const rel = std::vector<uint32_t>(1, 0x847d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x847d); auto const rel = std::vector<uint32_t>(1, 0x4301); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4301); auto const rel = std::vector<uint32_t>(1, 0x4645); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4645); auto const rel = std::vector<uint32_t>(1, 0x9d01); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d01); auto const rel = std::vector<uint32_t>(1, 0x9080); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9080); auto const rel = std::vector<uint32_t>(1, 0x723b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_015) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x723b); auto const rel = std::vector<uint32_t>(1, 0x5c27); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c27); auto const rel = std::vector<uint32_t>(1, 0x5c2d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c2d); auto const rel = std::vector<uint32_t>(1, 0x80b4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80b4); auto const rel = std::vector<uint32_t>(1, 0x579a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x579a); auto const rel = std::vector<uint32_t>(1, 0x59da); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x59da); auto const rel = std::vector<uint32_t>(1, 0x5ce3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ce3); auto const rel = std::vector<uint32_t>(1, 0x409a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x409a); auto const rel = std::vector<uint32_t>(1, 0x8f7a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f7a); auto const rel = std::vector<uint32_t>(1, 0x5004); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5004); auto const rel = std::vector<uint32_t>(1, 0x70d1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70d1); auto const rel = std::vector<uint32_t>(1, 0x73e7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x73e7); auto const rel = std::vector<uint32_t>(1, 0x7a91); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a91); auto const rel = std::vector<uint32_t>(1, 0x509c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x509c); auto const rel = std::vector<uint32_t>(1, 0x582f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x582f); auto const rel = std::vector<uint32_t>(1, 0x63fa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x63fa); auto const rel = std::vector<uint32_t>(1, 0x8c23); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c23); auto const rel = std::vector<uint32_t>(1, 0x8efa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8efa); auto const rel = std::vector<uint32_t>(1, 0x347e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x347e); auto const rel = std::vector<uint32_t>(1, 0x55c2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x55c2); auto const rel = std::vector<uint32_t>(1, 0x5ab1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ab1); auto const rel = std::vector<uint32_t>(1, 0x5fad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fad); auto const rel = std::vector<uint32_t>(1, 0x612e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x612e); auto const rel = std::vector<uint32_t>(1, 0x6416); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6416); auto const rel = std::vector<uint32_t>(1, 0x6447); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6447); auto const rel = std::vector<uint32_t>(1, 0x733a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x733a); auto const rel = std::vector<uint32_t>(1, 0x3a31); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3a31); auto const rel = std::vector<uint32_t>(1, 0x669a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x669a); auto const rel = std::vector<uint32_t>(1, 0x69a3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x69a3); auto const rel = std::vector<uint32_t>(1, 0x7464); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7464); auto const rel = std::vector<uint32_t>(1, 0x7476); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7476); auto const rel = std::vector<uint32_t>(1, 0x9059); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9059); auto const rel = std::vector<uint32_t>(1, 0x9065); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9065); auto const rel = std::vector<uint32_t>(1, 0x929a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x929a); auto const rel = std::vector<uint32_t>(1, 0x98d6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98d6); auto const rel = std::vector<uint32_t>(1, 0x9906); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9906); auto const rel = std::vector<uint32_t>(1, 0x5da2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5da2); auto const rel = std::vector<uint32_t>(1, 0x5da4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5da4); auto const rel = std::vector<uint32_t>(1, 0x7aaf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7aaf); auto const rel = std::vector<uint32_t>(1, 0x7ab0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7ab0); auto const rel = std::vector<uint32_t>(1, 0x4504); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4504); auto const rel = std::vector<uint32_t>(1, 0x991a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x991a); auto const rel = std::vector<uint32_t>(1, 0x7e47); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e47); auto const rel = std::vector<uint32_t>(1, 0x8b20); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b20); auto const rel = std::vector<uint32_t>(1, 0x8b21); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b21); auto const rel = std::vector<uint32_t>(1, 0x26fbe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x26fbe); auto const rel = std::vector<uint32_t>(1, 0x9390); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9390); auto const rel = std::vector<uint32_t>(1, 0x9cd0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9cd0); auto const rel = std::vector<uint32_t>(1, 0x4b19); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4b19); auto const rel = std::vector<uint32_t>(1, 0x98bb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x98bb); auto const rel = std::vector<uint32_t>(1, 0x8628); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8628); auto const rel = std::vector<uint32_t>(1, 0x908e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_016) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x908e); auto const rel = std::vector<uint32_t>(1, 0x9864); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9864); auto const rel = std::vector<uint32_t>(1, 0x9c29); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c29); auto const rel = std::vector<uint32_t>(1, 0x4ef8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4ef8); auto const rel = std::vector<uint32_t>(1, 0x5b8e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b8e); auto const rel = std::vector<uint32_t>(1, 0x5c86); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c86); auto const rel = std::vector<uint32_t>(1, 0x62ad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x62ad); auto const rel = std::vector<uint32_t>(1, 0x6773); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6773); auto const rel = std::vector<uint32_t>(1, 0x72d5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72d5); auto const rel = std::vector<uint32_t>(1, 0x54ac); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x54ac); auto const rel = std::vector<uint32_t>(1, 0x67fc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67fc); auto const rel = std::vector<uint32_t>(1, 0x82ed); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x82ed); auto const rel = std::vector<uint32_t>(1, 0x7711); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7711); auto const rel = std::vector<uint32_t>(1, 0x7a85); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a85); auto const rel = std::vector<uint32_t>(1, 0x7a88); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a88); auto const rel = std::vector<uint32_t>(1, 0x8200); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8200); auto const rel = std::vector<uint32_t>(1, 0x5060); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5060); auto const rel = std::vector<uint32_t>(1, 0x5a79); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5a79); auto const rel = std::vector<uint32_t>(1, 0x5d3e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d3e); auto const rel = std::vector<uint32_t>(1, 0x6e94); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e94); auto const rel = std::vector<uint32_t>(1, 0x699a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x699a); auto const rel = std::vector<uint32_t>(1, 0x84d4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x84d4); auto const rel = std::vector<uint32_t>(1, 0x9d22); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9d22); auto const rel = std::vector<uint32_t>(1, 0x9f3c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f3c); auto const rel = std::vector<uint32_t>(1, 0x95c4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95c4); auto const rel = std::vector<uint32_t>(1, 0x9a15); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9a15); auto const rel = std::vector<uint32_t>(1, 0x9f69); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f69); auto const rel = std::vector<uint32_t>(1, 0x9dd5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dd5); auto const rel = std::vector<uint32_t>(1, 0x7a7e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a7e); auto const rel = std::vector<uint32_t>(1, 0x8981); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8981); auto const rel = std::vector<uint32_t>(1, 0x94a5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94a5); auto const rel = std::vector<uint32_t>(1, 0x25052); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x25052); auto const rel = std::vector<uint32_t>(1, 0x836f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x836f); auto const rel = std::vector<uint32_t>(1, 0x7a94); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7a94); auto const rel = std::vector<uint32_t>(1, 0x888e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x888e); auto const rel = std::vector<uint32_t>(1, 0x7b44); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7b44); auto const rel = std::vector<uint32_t>(1, 0x8a4f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a4f); auto const rel = std::vector<uint32_t>(1, 0x846f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x846f); auto const rel = std::vector<uint32_t>(1, 0x718e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x718e); auto const rel = std::vector<uint32_t>(1, 0x899e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x899e); auto const rel = std::vector<uint32_t>(1, 0x977f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x977f); auto const rel = std::vector<uint32_t>(1, 0x735f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x735f); auto const rel = std::vector<uint32_t>(1, 0x9e5e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e5e); auto const rel = std::vector<uint32_t>(1, 0x25aaf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x25aaf); auto const rel = std::vector<uint32_t>(1, 0x85ac); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85ac); auto const rel = std::vector<uint32_t>(1, 0x66dc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x66dc); auto const rel = std::vector<uint32_t>(1, 0x71ff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x71ff); auto const rel = std::vector<uint32_t>(1, 0x825e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x825e); auto const rel = std::vector<uint32_t>(1, 0x77c5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x77c5); auto const rel = std::vector<uint32_t>(1, 0x85e5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x85e5); auto const rel = std::vector<uint32_t>(1, 0x8000); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8000); auto const rel = std::vector<uint32_t>(1, 0x7e85); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_017) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e85); auto const rel = std::vector<uint32_t>(1, 0x9dc2); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9dc2); auto const rel = std::vector<uint32_t>(1, 0x8b91); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8b91); auto const rel = std::vector<uint32_t>(1, 0x9470); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9470); auto const rel = std::vector<uint32_t>(1, 0x4f18); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f18); auto const rel = std::vector<uint32_t>(1, 0x5fe7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5fe7); auto const rel = std::vector<uint32_t>(1, 0x6538); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6538); auto const rel = std::vector<uint32_t>(1, 0x5466); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5466); auto const rel = std::vector<uint32_t>(1, 0x602e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x602e); auto const rel = std::vector<uint32_t>(1, 0x6cd1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6cd1); auto const rel = std::vector<uint32_t>(1, 0x5e7d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e7d); auto const rel = std::vector<uint32_t>(1, 0x60a0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x60a0); auto const rel = std::vector<uint32_t>(1, 0x900c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x900c); auto const rel = std::vector<uint32_t>(1, 0x9e80); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9e80); auto const rel = std::vector<uint32_t>(1, 0x6efa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6efa); auto const rel = std::vector<uint32_t>(1, 0x6182); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6182); auto const rel = std::vector<uint32_t>(1, 0x512a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x512a); auto const rel = std::vector<uint32_t>(1, 0x5698); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5698); auto const rel = std::vector<uint32_t>(1, 0x7000); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7000); auto const rel = std::vector<uint32_t>(1, 0x913e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x913e); auto const rel = std::vector<uint32_t>(1, 0x6acc); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6acc); auto const rel = std::vector<uint32_t>(1, 0x7e8b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7e8b); auto const rel = std::vector<uint32_t>(1, 0x8030); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8030); auto const rel = std::vector<uint32_t>(1, 0x5c22); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c22); auto const rel = std::vector<uint32_t>(1, 0x5c24); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5c24); auto const rel = std::vector<uint32_t>(1, 0x7531); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7531); auto const rel = std::vector<uint32_t>(1, 0x6c8b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6c8b); auto const rel = std::vector<uint32_t>(1, 0x72b9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72b9); auto const rel = std::vector<uint32_t>(1, 0x3f55); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3f55); auto const rel = std::vector<uint32_t>(1, 0x233de); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x233de); auto const rel = std::vector<uint32_t>(1, 0x6cb9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6cb9); auto const rel = std::vector<uint32_t>(1, 0x80ac); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80ac); auto const rel = std::vector<uint32_t>(1, 0x90ae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x90ae); auto const rel = std::vector<uint32_t>(1, 0x6023); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6023); auto const rel = std::vector<uint32_t>(1, 0x65bf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x65bf); auto const rel = std::vector<uint32_t>(1, 0x75a3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x75a3); auto const rel = std::vector<uint32_t>(1, 0x5cf3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cf3); auto const rel = std::vector<uint32_t>(1, 0x6d5f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6d5f); auto const rel = std::vector<uint32_t>(1, 0x79de); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x79de); auto const rel = std::vector<uint32_t>(1, 0x4343); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4343); auto const rel = std::vector<uint32_t>(1, 0x94c0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94c0); auto const rel = std::vector<uint32_t>(1, 0x5064); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5064); auto const rel = std::vector<uint32_t>(1, 0x839c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x839c); auto const rel = std::vector<uint32_t>(1, 0x83b8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83b8); auto const rel = std::vector<uint32_t>(1, 0x86b0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x86b0); auto const rel = std::vector<uint32_t>(1, 0x8a27); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a27); auto const rel = std::vector<uint32_t>(1, 0x6e38); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e38); auto const rel = std::vector<uint32_t>(1, 0x7336); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7336); auto const rel = std::vector<uint32_t>(1, 0x9030); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9030); auto const rel = std::vector<uint32_t>(1, 0x90f5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x90f5); auto const rel = std::vector<uint32_t>(1, 0x9c7f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c7f); auto const rel = std::vector<uint32_t>(1, 0x6962); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_018) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6962); auto const rel = std::vector<uint32_t>(1, 0x7337); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7337); auto const rel = std::vector<uint32_t>(1, 0x904a); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x904a); auto const rel = std::vector<uint32_t>(1, 0x923e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x923e); auto const rel = std::vector<uint32_t>(1, 0x9c89); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9c89); auto const rel = std::vector<uint32_t>(1, 0x8f0f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f0f); auto const rel = std::vector<uint32_t>(1, 0x99c0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x99c0); auto const rel = std::vector<uint32_t>(1, 0x8763); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8763); auto const rel = std::vector<uint32_t>(1, 0x9b77); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b77); auto const rel = std::vector<uint32_t>(1, 0x8555); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8555); auto const rel = std::vector<uint32_t>(1, 0x8f36); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8f36); auto const rel = std::vector<uint32_t>(1, 0x9b8b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9b8b); auto const rel = std::vector<uint32_t>(1, 0x6afe); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6afe); auto const rel = std::vector<uint32_t>(1, 0x53cb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x53cb); auto const rel = std::vector<uint32_t>(1, 0x6709); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6709); auto const rel = std::vector<uint32_t>(1, 0x4e23); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4e23); auto const rel = std::vector<uint32_t>(1, 0x5363); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5363); auto const rel = std::vector<uint32_t>(1, 0x9149); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9149); auto const rel = std::vector<uint32_t>(1, 0x82c3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x82c3); auto const rel = std::vector<uint32_t>(1, 0x3dad); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x3dad); auto const rel = std::vector<uint32_t>(1, 0x7f91); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f91); auto const rel = std::vector<uint32_t>(1, 0x5eae); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5eae); auto const rel = std::vector<uint32_t>(1, 0x682f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x682f); auto const rel = std::vector<uint32_t>(1, 0x7f90); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7f90); auto const rel = std::vector<uint32_t>(1, 0x6884); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6884); auto const rel = std::vector<uint32_t>(1, 0x8048); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8048); auto const rel = std::vector<uint32_t>(1, 0x811c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x811c); auto const rel = std::vector<uint32_t>(1, 0x83a0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83a0); auto const rel = std::vector<uint32_t>(1, 0x94d5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x94d5); auto const rel = std::vector<uint32_t>(1, 0x6e75); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e75); auto const rel = std::vector<uint32_t>(1, 0x870f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x870f); auto const rel = std::vector<uint32_t>(1, 0x7989); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7989); auto const rel = std::vector<uint32_t>(1, 0x92aa); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x92aa); auto const rel = std::vector<uint32_t>(1, 0x4b00); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4b00); auto const rel = std::vector<uint32_t>(1, 0x69f1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x69f1); auto const rel = std::vector<uint32_t>(1, 0x7256); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7256); auto const rel = std::vector<uint32_t>(1, 0x9edd); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9edd); auto const rel = std::vector<uint32_t>(1, 0x61ee); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61ee); auto const rel = std::vector<uint32_t>(1, 0x2e80); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x2e80); auto const rel = std::vector<uint32_t>(1, 0x53c8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x53c8); auto const rel = std::vector<uint32_t>(1, 0x53f3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x53f3); auto const rel = std::vector<uint32_t>(1, 0x5e7c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5e7c); auto const rel = std::vector<uint32_t>(1, 0x4f51); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f51); auto const rel = std::vector<uint32_t>(1, 0x4f91); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4f91); auto const rel = std::vector<uint32_t>(1, 0x72d6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x72d6); auto const rel = std::vector<uint32_t>(1, 0x7cff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7cff); auto const rel = std::vector<uint32_t>(1, 0x54ca); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x54ca); auto const rel = std::vector<uint32_t>(1, 0x56ff); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x56ff); auto const rel = std::vector<uint32_t>(1, 0x59f7); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x59f7); auto const rel = std::vector<uint32_t>(1, 0x5ba5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ba5); auto const rel = std::vector<uint32_t>(1, 0x5cdf); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5cdf); auto const rel = std::vector<uint32_t>(1, 0x67da); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } } TEST(tailoring, zh_zhuyin_019_019) { { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x67da); auto const rel = std::vector<uint32_t>(1, 0x7270); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7270); auto const rel = std::vector<uint32_t>(1, 0x8bf1); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8bf1); auto const rel = std::vector<uint32_t>(1, 0x5500); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5500); auto const rel = std::vector<uint32_t>(1, 0x7950); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7950); auto const rel = std::vector<uint32_t>(1, 0x8ff6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ff6); auto const rel = std::vector<uint32_t>(1, 0x4001); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4001); auto const rel = std::vector<uint32_t>(1, 0x86b4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x86b4); auto const rel = std::vector<uint32_t>(1, 0x4eb4); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4eb4); auto const rel = std::vector<uint32_t>(1, 0x8c81); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8c81); auto const rel = std::vector<uint32_t>(1, 0x91c9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x91c9); auto const rel = std::vector<uint32_t>(1, 0x916d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x916d); auto const rel = std::vector<uint32_t>(1, 0x8a98); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8a98); auto const rel = std::vector<uint32_t>(1, 0x9f2c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9f2c); auto const rel = std::vector<uint32_t>(1, 0x5b67); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b67); auto const rel = std::vector<uint32_t>(1, 0x848f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x848f); auto const rel = std::vector<uint32_t>(1, 0x7257); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7257); auto const rel = std::vector<uint32_t>(1, 0x6079); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6079); auto const rel = std::vector<uint32_t>(1, 0x5266); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5266); auto const rel = std::vector<uint32_t>(1, 0x70df); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x70df); auto const rel = std::vector<uint32_t>(1, 0x73da); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x73da); auto const rel = std::vector<uint32_t>(1, 0x80ed); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x80ed); auto const rel = std::vector<uint32_t>(1, 0x5063); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5063); auto const rel = std::vector<uint32_t>(1, 0x5571); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5571); auto const rel = std::vector<uint32_t>(1, 0x5d26); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5d26); auto const rel = std::vector<uint32_t>(1, 0x393f); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x393f); auto const rel = std::vector<uint32_t>(1, 0x6dca); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6dca); auto const rel = std::vector<uint32_t>(1, 0x6df9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6df9); auto const rel = std::vector<uint32_t>(1, 0x7109); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7109); auto const rel = std::vector<uint32_t>(1, 0x7111); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7111); auto const rel = std::vector<uint32_t>(1, 0x479b); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x479b); auto const rel = std::vector<uint32_t>(1, 0x9609); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9609); auto const rel = std::vector<uint32_t>(1, 0x6e6e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6e6e); auto const rel = std::vector<uint32_t>(1, 0x7312); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7312); auto const rel = std::vector<uint32_t>(1, 0x814c); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x814c); auto const rel = std::vector<uint32_t>(1, 0x83f8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x83f8); auto const rel = std::vector<uint32_t>(1, 0x7159); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7159); auto const rel = std::vector<uint32_t>(1, 0x787d); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x787d); auto const rel = std::vector<uint32_t>(1, 0x5ae3); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5ae3); auto const rel = std::vector<uint32_t>(1, 0x6f39); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x6f39); auto const rel = std::vector<uint32_t>(1, 0x4167); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x4167); auto const rel = std::vector<uint32_t>(1, 0x9122); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9122); auto const rel = std::vector<uint32_t>(1, 0x9183); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9183); auto const rel = std::vector<uint32_t>(1, 0x95b9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x95b9); auto const rel = std::vector<uint32_t>(1, 0x5b2e); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x5b2e); auto const rel = std::vector<uint32_t>(1, 0x61e8); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61e8); auto const rel = std::vector<uint32_t>(1, 0x7bf6); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x7bf6); auto const rel = std::vector<uint32_t>(1, 0x61d5); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x61d5); auto const rel = std::vector<uint32_t>(1, 0x81d9); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x81d9); auto const rel = std::vector<uint32_t>(1, 0x9eeb); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x9eeb); auto const rel = std::vector<uint32_t>(1, 0x8ba0); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } { // greater than (or equal to, for =) preceeding cps auto const res = std::vector<uint32_t>(1, 0x8ba0); auto const rel = std::vector<uint32_t>(1, 0x4e25); std::string const res_str = to_string(res); std::string const rel_str = to_string(rel); auto const res_view = as_utf32(res); auto const rel_view = as_utf32(rel); EXPECT_EQ(collate( res.begin(), res.end(), rel.begin(), rel.end(), table(), collation_strength::primary), -1); EXPECT_EQ(collate( res_view.begin(), res_view.end(), rel_view.begin(), rel_view.end(), table(), collation_strength::primary), -1); } }
sbp = function(n, a) { bundle = list(0, numeric(0)) for (j in seq(n)) { bundle = snap(bundle[[1]], bundle[[2]], a) } c(bundle[[2]], 1 - sum(bundle[[2]])) } snap = function(acc, bun, a) { b = rbeta(1, 1, a) stick = exp(log(b) + acc) nacc = log (1 - b) + acc nbun = c(bun, stick) list(nacc, nbun) }
Formal statement is: lemma filterlim_sequentially_iff_filterlim_real: "filterlim f sequentially F \<longleftrightarrow> filterlim (\<lambda>x. real (f x)) at_top F" (is "?lhs = ?rhs") Informal statement is: A sequence $f$ converges to a filter $F$ if and only if the sequence of real numbers $f_n$ converges to $F$.
State Before: 𝕜 : Type u_1 inst✝⁸ : NontriviallyNormedField 𝕜 E : Type u_2 inst✝⁷ : NormedAddCommGroup E inst✝⁶ : NormedSpace 𝕜 E F : Type u_3 inst✝⁵ : NormedAddCommGroup F inst✝⁴ : NormedSpace 𝕜 F G : Type ?u.427827 inst✝³ : NormedAddCommGroup G inst✝² : NormedSpace 𝕜 G G' : Type ?u.427922 inst✝¹ : NormedAddCommGroup G' inst✝ : NormedSpace 𝕜 G' f f₀ f₁ g : E → F f' f₀' f₁' g' e : E →L[𝕜] F x : E s t : Set E L L₁ L₂ : Filter E h : Differentiable 𝕜 fun y => -f y ⊢ Differentiable 𝕜 f State After: no goals Tactic: simpa only [neg_neg] using h.neg
module Numeral.Finite.Oper where open import Data open import Data.Boolean.Stmt open import Data.Option open import Logic.Propositional open import Logic.Predicate import Lvl open import Numeral.Finite as 𝕟 using (𝕟 ; 𝕟₌ ; 𝕟-to-ℕ) open import Numeral.Finite.Bound open import Numeral.Natural hiding (𝟎 ; 𝐒 ; 𝐏) open import Numeral.Natural.Function open import Numeral.Natural.Function.Proofs import Numeral.Natural.Oper as ℕ import Numeral.Natural.Oper.Comparisons as ℕ open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Syntax.Number module Exact where -- Predecessor bounded at the minimum (0) for both the value and the maximum. -- Example: (𝐏₀(5): 𝕟(8)) = (4: 𝕟(7)) 𝐏₀ : ∀{n} → 𝕟(ℕ.𝐒(ℕ.𝐒(n))) → 𝕟(ℕ.𝐒(n)) 𝐏₀(𝕟.𝟎) = 𝕟.𝟎 𝐏₀(𝕟.𝐒(n)) = n -- Addition for both the value and the maximum. -- Example: (5: 𝕟(8)) + (4: 𝕟(6)) = ((5+4): 𝕟(8+6)) = (9: 𝕟(14)) _+_ : ∀{b₁ b₂} → 𝕟(b₁) → 𝕟(b₂) → 𝕟(b₁ ℕ.+ b₂) _+_ {ℕ.𝐒(b₁)}{ℕ.𝐒(b₂)} 𝕟.𝟎 𝕟.𝟎 = 𝕟.𝟎 _+_ {ℕ.𝐒(b₁)}{ℕ.𝐒(b₂)} 𝕟.𝟎 (𝕟.𝐒(b)) = 𝕟.𝐒(𝕟.𝟎{b₁} + b) _+_ {ℕ.𝐒(b₁)}{ℕ.𝐒(b₂)} (𝕟.𝐒(a)) b = 𝕟.𝐒(a + b) -- Distance between two numbers. -- Examples: -- (3: 𝕟(8)) 𝄩 (5: 𝕟(6)) = ((3𝄩5): 𝕟(max 8 6)) = (2: 𝕟(8)) -- (5: 𝕟(8)) 𝄩 (3: 𝕟(6)) = ((5𝄩3): 𝕟(max 8 6)) = (2: 𝕟(8)) -- (7: 𝕟(8)) 𝄩 (0: 𝕟(6)) = ((7𝄩0): 𝕟(max 8 6)) = (7: 𝕟(8)) _𝄩_ : ∀{b₁ b₂} → 𝕟(b₁) → 𝕟(b₂) → 𝕟(max b₁ b₂) _𝄩_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} 𝕟.𝟎 𝕟.𝟎 = 𝕟.𝟎 _𝄩_ {ℕ.𝐒 ℕ.𝟎} {ℕ.𝐒 b₂} 𝕟.𝟎 (𝕟.𝐒 b) = 𝕟.𝐒 b _𝄩_ {ℕ.𝐒 (ℕ.𝐒 b₁)} {ℕ.𝐒 b₂} 𝕟.𝟎 (𝕟.𝐒 b) = 𝕟.𝐒(𝕟.𝟎 𝄩 b) _𝄩_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} (𝕟.𝐒 a) (𝕟.𝐒 b) = bound-𝐒(a 𝄩 b) _𝄩_ {ℕ.𝐒 b₁} {ℕ.𝐒 ℕ.𝟎} (𝕟.𝐒 a) 𝕟.𝟎 = 𝕟.𝐒 a _𝄩_ {ℕ.𝐒 b₁} {ℕ.𝐒 (ℕ.𝐒 b₂)} (𝕟.𝐒 a) 𝕟.𝟎 = 𝕟.𝐒(a 𝄩 𝕟.𝟎) _⋅_ : ∀{b₁ b₂} → 𝕟(b₁) → 𝕟(b₂) → 𝕟(b₁ ℕ.⋅ b₂) _⋅_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} a 𝕟.𝟎 = 𝕟.𝟎 _⋅_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} a (𝕟.𝐒 b) = a + (a ⋅ b) module Bounded where -- Predecessor bounded at the minimum (0) for the value only. -- Example: (𝐏₀(5): 𝕟(8)) = (4: 𝕟(8)) 𝐏₀ : ∀{n} → 𝕟(n) → 𝕟(n) 𝐏₀ {ℕ.𝐒(b)} (𝕟.𝟎) = 𝕟.𝟎 𝐏₀ {ℕ.𝐒(b)} (𝕟.𝐒(𝕟.𝟎)) = 𝕟.𝟎 𝐏₀ {ℕ.𝐒(b)} (𝕟.𝐒(𝕟.𝐒(n))) = 𝕟.𝐒(𝐏₀ {b} (𝕟.𝐒(n))) module Total where 𝐒 : ∀{b} → (n : 𝕟(b)) → ⦃ _ : IsTrue(ℕ.𝐒(𝕟-to-ℕ (n)) ℕ.<? b) ⦄ → 𝕟(b) 𝐒 {ℕ.𝐒(ℕ.𝐒(b))} (𝕟.𝟎) = 𝕟.𝐒(𝕟.𝟎) 𝐒 {ℕ.𝐒(ℕ.𝐒(b))} (𝕟.𝐒(n)) = 𝕟.𝐒(𝐒(n)) module Optional where minimum : ∀{n} → Option(𝕟(n)) minimum{ℕ.𝟎} = None minimum{ℕ.𝐒(_)} = Some 𝕟.minimum maximum : ∀{n} → Option(𝕟(n)) maximum{ℕ.𝟎} = None maximum{ℕ.𝐒(n)} = Some 𝕟.maximum _+₀ₗ_ : ∀{b₁ b₂} → Option(𝕟(b₁)) → 𝕟(b₂) → 𝕟(b₁ ℕ.+ b₂) _+₀ₗ_ None 𝕟.𝟎 = 𝕟.𝟎 _+₀ₗ_ {b₁} None (𝕟.𝐒(b)) = 𝕟.𝐒(_+₀ₗ_ {b₁} None b) _+₀ₗ_ (Some a) b = a Exact.+ b _+₀ᵣ_ : ∀{b₁ b₂} → 𝕟(b₁) → Option(𝕟(b₂)) → 𝕟(b₁ ℕ.+ b₂) _+₀ᵣ_ 𝕟.𝟎 None = 𝕟.𝟎 _+₀ᵣ_ (𝕟.𝐒(a)) None = 𝕟.𝐒(_+₀ᵣ_ a None) {-# CATCHALL #-} _+₀ᵣ_ a (Some b) = a Exact.+ b module Unclosed where _+ₙₗ_ : ∀{b₂} → (b₁ : ℕ) → 𝕟(b₂) → 𝕟(b₁ ℕ.+ b₂) ℕ.𝟎 +ₙₗ b = b ℕ.𝐒(a) +ₙₗ b = 𝕟.𝐒(a +ₙₗ b) _+ₙᵣ_ : ∀{b₁} → 𝕟(b₁) → (b₂ : ℕ) → 𝕟(b₁ ℕ.+ b₂) a +ₙᵣ ℕ.𝟎 = a a +ₙᵣ ℕ.𝐒(b) = 𝕟.𝐒(a +ₙᵣ b) -- Example: shrink-subtract(5) (7 : 𝕟(6 + 5)) = (2 : 𝕟(6)) shrink-subtractₗ : ∀{b₁} → (b₂ : ℕ) → 𝕟(ℕ.𝐒(b₁) ℕ.+ b₂) → 𝕟(ℕ.𝐒(b₁)) shrink-subtractₗ _ 𝕟.𝟎 = 𝕟.𝟎 shrink-subtractₗ ℕ.𝟎 (𝕟.𝐒 a) = 𝕟.𝐒 a shrink-subtractₗ {ℕ.𝟎} (ℕ.𝐒 b₂) (𝕟.𝐒 a) = 𝕟.𝟎 shrink-subtractₗ {ℕ.𝐒 b₁} (ℕ.𝐒 b₂) (𝕟.𝐒 a) = shrink-subtractₗ {ℕ.𝐒 b₁} (b₂) (a) shrink-subtractᵣ : (b₁ : ℕ) → ∀{b₂} → 𝕟(b₁ ℕ.+ ℕ.𝐒(b₂)) → 𝕟(ℕ.𝐒(b₂)) shrink-subtractᵣ _ 𝕟.𝟎 = 𝕟.𝟎 shrink-subtractᵣ ℕ.𝟎 (𝕟.𝐒 a) = 𝕟.𝐒 a shrink-subtractᵣ (ℕ.𝐒 b₁) {ℕ.𝟎} (𝕟.𝐒 a) = 𝕟.𝟎 shrink-subtractᵣ (ℕ.𝐒 b₁) {ℕ.𝐒 b₂} (𝕟.𝐒 a) = shrink-subtractᵣ (b₁) {ℕ.𝐒 b₂} (a) {-_⋅ₙₗ_ : ∀{b₂} → (b₁ : ℕ) → 𝕟(b₂) → 𝕟(ℕ.𝐒(b₁ ℕ.⋅ b₂)) _⋅ₙₗ_ {ℕ.𝐒 _} ℕ.𝟎 _ = 𝕟.𝟎 _⋅ₙₗ_ {ℕ.𝐒 _} (ℕ.𝐒 a) b = {!b Exact.+ (a ⋅ₙₗ b)!} -} _⋅ₙᵣ_ : ∀{b₁} → 𝕟(b₁) → (b₂ : ℕ) → 𝕟(ℕ.𝐒(b₁ ℕ.⋅ b₂)) -- TODO: Bounds is too great _⋅ₙᵣ_ {ℕ.𝐒 _} a ℕ.𝟎 = 𝕟.𝟎 _⋅ₙᵣ_ {ℕ.𝐒 _} a (ℕ.𝐒 b) = a Exact.+ (a ⋅ₙᵣ b) module Wrapping where -- Wrapping subtraction. -- Essentially: _[−]_ {b₁}{b₂} a b = (a −ℤ b) mod b₁ _[−]_ : ∀{b₁ b₂} → 𝕟(b₁) → 𝕟(b₂) → 𝕟(b₁) _[−]_ {_} {ℕ.𝐒 _} a 𝕟.𝟎 = a _[−]_ {ℕ.𝐒 b₁} {ℕ.𝐒 _} 𝕟.𝟎 (𝕟.𝐒 b) = 𝕟.maximum {b₁} [−] b _[−]_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} (𝕟.𝐒 a) (𝕟.𝐒 b) = _[−]_ {ℕ.𝐒 b₁}{b₂} (bound-𝐒 a) b -- Wrapping negation (Flipping around the symmetric point). -- Essentially: [−]_ {b} n = (−ℤ n) mod b [−]_ : ∀{b} → 𝕟(b) → 𝕟(b) [−]_ {ℕ.𝐒 b} n = 𝕟.maximum {b} [−] n {- TODO: Cannot solve first. Unsure why [𝐒]-not-0 : ∀{b : ℕ}{n : 𝕟(ℕ.𝐒(b))} → (𝐒{b}(n) ≢ 𝟎{ℕ.𝐒(b)}) [𝐒]-not-0 () 𝐏keep : ∀{b} → (n : 𝕟(𝐒(b))) → ⦃ _ : n ≢ 𝟎 ⦄ → 𝕟(𝐒(b)) 𝐏keep {ℕ.𝟎} (𝟎) ⦃ proof ⦄ with proof([≡]-intro) ... | () 𝐏keep {ℕ.𝐒(b)} (𝟎) ⦃ _ ⦄ = 𝟎 𝐏keep {ℕ.𝐒(b)} (𝐒(𝟎)) ⦃ _ ⦄ = 𝟎 𝐏keep {ℕ.𝐒(b)} (𝐒(𝐒(n))) ⦃ proof ⦄ = 𝐒(𝐏keep {b} (𝐒(n)) ⦃ [𝐒]-not-0 ⦄) -} -- _ : ∀{b} → (n : 𝕟(b)) → (𝕟-to-ℕ (n) < b) -- _+small_ : ∀{b₁ b₂} → (x : 𝕟(𝐒(b₁))) → (y : 𝕟(𝐒(b₂))) → 𝕟(ℕ.𝐒(𝕟-to-ℕ (x) ℕ.+ 𝕟-to-ℕ (y))) -- _+small_ 𝟎 𝟎 = 𝟎 -- _+small_ {b₁} (𝐒(a)) 𝟎 = 𝐒(a +small 𝟎) -- _+small_ a (𝐒(b)) = 𝐒(a +small b) -- _−small_ : ∀{b} → (x : 𝕟(𝐒(b))) → (y : 𝕟(ℕ.𝐒(𝕟-to-ℕ (x)))) → 𝕟(ℕ.𝐒(𝕟-to-ℕ (x) ℕ.−₀ 𝕟-to-ℕ (y))) -- 𝟎 −small 𝟎 = 𝟎 -- 𝐒(a) −small 𝟎 = 𝐒(a −small 𝟎) -- 𝐒(a) −small 𝐒(b) = a −small b {- TODO: Will not work like this -- Modulo subtraction. -- Essentially: a [−] b mod n = (a −ℤ b) mod n _[−]_mod_ : ℕ → ℕ → (n : ℕ) → 𝕟₌(n) _ [−] _ mod 𝟎 = 𝟎 𝟎 [−] 𝟎 mod 𝐒(n) = 𝟎 𝐒(a) [−] 𝟎 mod 𝐒(n) = a [−] n mod 𝐒(n) 𝟎 [−] 𝐒(b) mod 𝐒(n) = n [−] b mod 𝐒(n) 𝐒(a) [−] 𝐒(b) mod 𝐒(n) = a [−] b mod 𝐒(n) open import Data test1 : [−]_ {4} 1 ≡ 3 test1 = [≡]-intro -} -- _−_ : ∀{b} → (x : 𝕟(𝐒(b))) → (y : 𝕟(ℕ.𝐒(𝕟-to-ℕ (x)))) → 𝕟(𝐒(b)) -- 𝟎 − 𝟎 = 𝟎 -- 𝐒(a) − 𝟎 = 𝐒(a) -- 𝐒(a) − 𝐒(b) = bound-𝐒(a − b) -- TODO: Wrapping and bounded operations
function b = r8col_normalize_li ( m, n, a ) %*****************************************************************************80 % %% R8COL_NORMALIZE_LI normalizes an R8COL with the column infinity norm. % % Discussion: % % Each column is scaled so that the entry of maximum norm has the value 1. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 08 February 2012 % % Author: % % John Burkardt % % Parameters: % % Input, integer M, N, the number of rows and columns. % % Input, real A(M,N), the array to be examined. % % Output, real B(M,N), the normalize array. % b(1:m,1:n) = a(1:m,1:n); for j = 1 : n c = a(1,j); for i = 2 : m if ( abs ( c ) < abs ( a(i,j) ) ) c = a(i,j); end end if ( c ~= 0.0 ) b(1:m,j) = b(1:m,j) / c; end end return end
[STATEMENT] lemma singl_in_Bpow: assumes rc: "Card_order r" and r: "Field r \<noteq> {}" and a: "a \<in> A" shows "{a} \<in> Bpow r A" [PROOF STATE] proof (prove) goal (1 subgoal): 1. {a} \<in> Bpow r A [PROOF STEP] proof- [PROOF STATE] proof (state) goal (1 subgoal): 1. {a} \<in> Bpow r A [PROOF STEP] have "|{a}| \<le>o r" [PROOF STATE] proof (prove) goal (1 subgoal): 1. |{a}| \<le>o r [PROOF STEP] using r rc [PROOF STATE] proof (prove) using this: Field r \<noteq> {} Card_order r goal (1 subgoal): 1. |{a}| \<le>o r [PROOF STEP] by auto [PROOF STATE] proof (state) this: |{a}| \<le>o r goal (1 subgoal): 1. {a} \<in> Bpow r A [PROOF STEP] thus ?thesis [PROOF STATE] proof (prove) using this: |{a}| \<le>o r goal (1 subgoal): 1. {a} \<in> Bpow r A [PROOF STEP] unfolding Bpow_def [PROOF STATE] proof (prove) using this: |{a}| \<le>o r goal (1 subgoal): 1. {a} \<in> {X. X \<subseteq> A \<and> |X| \<le>o r} [PROOF STEP] using a [PROOF STATE] proof (prove) using this: |{a}| \<le>o r a \<in> A goal (1 subgoal): 1. {a} \<in> {X. X \<subseteq> A \<and> |X| \<le>o r} [PROOF STEP] by auto [PROOF STATE] proof (state) this: {a} \<in> Bpow r A goal: No subgoals! [PROOF STEP] qed
This entry was posted on 星期二, 二月 14th, 2017 at 9:42 上午 and is filed under 全球报导. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.
Goalgetters is a state of the art indoor soccer field located inside the Davis Athletic Club, based on European smallsided soccer games. They offer several adult sports and youth sports: Adult Night Leagues (coed, mens and womens) Youth Sports Childrens indoor soccer training programs designed to teach kids the world’s most popular sport (ages three to ten) 2year old soccer playtime classes Field Rental Birthday Parties 20090901 12:09:36 nbsp Coach Steve and all the other coaches are wonderful. My kids loved this program. Users/JenniferHolman 20091030 10:35:38 nbsp oh man goalgetters is so much fun! The kids have a great time in the youth program, and playing in the adult league is super fun too! I highly recommend both to everyone! Users/tmbear 20101123 13:42:52 nbsp So much fun! On my second call I spoke to Steve (I believe) who got me playing that night! Loved it. Users/KelseyCondell
{-| Module: MachineLearning.Optimization.GradientDescent Description: Gradient Descent Copyright: (c) Alexander Ignatyev, 2016 License: BSD-3 Stability: experimental Portability: POSIX -} module MachineLearning.Optimization.GradientDescent ( gradientDescent ) where import MachineLearning.Types (R, Vector, Matrix) import MachineLearning.Regularization (Regularization) import qualified Data.Vector.Storable as V import qualified Numeric.LinearAlgebra as LA import qualified MachineLearning.Model as Model -- | Gradient Descent method implementation. See "MachineLearning.Regression" for usage details. gradientDescent :: Model.Model a => R-> a -> R -> Int -> Regularization -> Matrix -> Vector -> Vector -> (Vector, Matrix) gradientDescent alpha model eps maxIters lambda x y theta = helper theta maxIters [] where gradient = Model.gradient model lambda cost = Model.cost model lambda helper theta nIters optPath = let theta' = theta - (LA.scale alpha (gradient x y theta)) j = cost x y theta' gradientTest = LA.norm_2 (theta' - theta) < eps optPathRow = V.concat [LA.vector [(fromIntegral $ maxIters - nIters), j], theta'] optPath' = optPathRow : optPath in if gradientTest || nIters <= 1 then (theta, LA.fromRows $ reverse optPath') else helper theta' (nIters - 1) optPath'
using HTMLParser using Test @testset "HTMLParser.jl" begin # Write your tests here. end
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.RadicalIdeal where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Function open import Cubical.Foundations.Powerset open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Sum hiding (map) open import Cubical.Data.FinData hiding (elim) open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-comm to +ℕ-comm ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm ; _choose_ to _ℕchoose_ ; snotz to ℕsnotz) open import Cubical.Data.Nat.Order open import Cubical.HITs.PropositionalTruncation as PT open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Ideal open import Cubical.Algebra.CommRing.FGIdeal open import Cubical.Algebra.CommRing.BinomialThm open import Cubical.Algebra.Ring.Properties open import Cubical.Algebra.Ring.BigOps open import Cubical.Algebra.RingSolver.ReflectionSolving private variable ℓ : Level module _ (R' : CommRing ℓ) where private R = fst R' open CommRingStr (snd R') open RingTheory (CommRing→Ring R') open Sum (CommRing→Ring R') open CommRingTheory R' open Exponentiation R' open BinomialThm R' open isCommIdeal √ : ℙ R → ℙ R --\surd √ I x = (∃[ n ∈ ℕ ] x ^ n ∈ I) , isPropPropTrunc ^∈√→∈√ : ∀ (I : ℙ R) (x : R) (n : ℕ) → x ^ n ∈ √ I → x ∈ √ I ^∈√→∈√ I x n = map (λ { (m , [xⁿ]ᵐ∈I) → (n ·ℕ m) , subst-∈ I (sym (^-rdist-·ℕ x n m)) [xⁿ]ᵐ∈I }) ∈→∈√ : ∀ (I : ℙ R) (x : R) → x ∈ I → x ∈ √ I ∈→∈√ I _ x∈I = ∣ 1 , subst-∈ I (sym (·Rid _)) x∈I ∣ √OfIdealIsIdeal : ∀ (I : ℙ R) → isCommIdeal R' I → isCommIdeal R' (√ I) +Closed (√OfIdealIsIdeal I ici) {x = x} {y = y} = map2 +ClosedΣ where +ClosedΣ : Σ[ n ∈ ℕ ] x ^ n ∈ I → Σ[ n ∈ ℕ ] y ^ n ∈ I → Σ[ n ∈ ℕ ] (x + y) ^ n ∈ I +ClosedΣ (n , xⁿ∈I) (m , yᵐ∈I) = (n +ℕ m) , subst-∈ I (sym (BinomialThm (n +ℕ m) _ _)) ∑Binomial∈I where binomialCoeff∈I : ∀ i → ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ∈ I binomialCoeff∈I i with ≤-+-split n m (toℕ i) (pred-≤-pred (toℕ<n i)) ... | inl n≤i = subst-∈ I (sym path) (·Closed ici _ xⁿ∈I) where useSolver : ∀ a b c d → a · (b · c) · d ≡ a · b · d · c useSolver = solve R' path : ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡ ((n +ℕ m) choose toℕ i) · x ^ (toℕ i ∸ n) · y ^ (n +ℕ m ∸ toℕ i) · x ^ n path = ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ k → ((n +ℕ m) choose toℕ i) · x ^ k · y ^ (n +ℕ m ∸ toℕ i)) (sym (≤-∸-+-cancel n≤i)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ ((toℕ i ∸ n) +ℕ n) · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ z → ((n +ℕ m) choose toℕ i) · z · y ^ (n +ℕ m ∸ toℕ i)) (sym (·-of-^-is-^-of-+ x (toℕ i ∸ n) n)) ⟩ ((n +ℕ m) choose toℕ i) · (x ^ (toℕ i ∸ n) · x ^ n) · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ useSolver _ _ _ _ ⟩ ((n +ℕ m) choose toℕ i) · x ^ (toℕ i ∸ n) · y ^ (n +ℕ m ∸ toℕ i) · x ^ n ∎ ... | inr m≤n+m-i = subst-∈ I (sym path) (·Closed ici _ yᵐ∈I) where path : ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m path = ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (n +ℕ m ∸ toℕ i) ≡⟨ cong (λ k → ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ k) (sym (≤-∸-+-cancel m≤n+m-i)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ (((n +ℕ m ∸ toℕ i) ∸ m) +ℕ m) ≡⟨ cong (((n +ℕ m) choose toℕ i) · x ^ toℕ i ·_) (sym (·-of-^-is-^-of-+ y ((n +ℕ m ∸ toℕ i) ∸ m) m)) ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · (y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m) ≡⟨ ·Assoc _ _ _ ⟩ ((n +ℕ m) choose toℕ i) · x ^ toℕ i · y ^ ((n +ℕ m ∸ toℕ i) ∸ m) · y ^ m ∎ ∑Binomial∈I : ∑ (BinomialVec (n +ℕ m) x y) ∈ I ∑Binomial∈I = ∑Closed R' (I , ici) (BinomialVec (n +ℕ m) _ _) binomialCoeff∈I contains0 (√OfIdealIsIdeal I ici) = ∣ 1 , subst-∈ I (sym (0LeftAnnihilates 1r)) (ici .contains0) ∣ ·Closed (√OfIdealIsIdeal I ici) r = map λ { (n , xⁿ∈I) → n , subst-∈ I (sym (^-ldist-· r _ n)) (ici .·Closed (r ^ n) xⁿ∈I) } -- important lemma for characterization of the Zariski lattice √FGIdealChar : {n : ℕ} (V : FinVec R n) (I : CommIdeal R') → √ (fst ⟨ V ⟩[ R' ]) ⊆ √ (fst I) ≃ (∀ i → V i ∈ √ (fst I)) √FGIdealChar V I = isEquivPropBiimpl→Equiv (⊆-isProp (√ (fst ⟨ V ⟩[ R' ])) (√ (fst I))) (isPropΠ (λ _ → √ (fst I) _ .snd)) .fst (ltrImpl , rtlImpl) where open KroneckerDelta (CommRing→Ring R') ltrImpl : √ (fst ⟨ V ⟩[ R' ]) ⊆ √ (fst I) → (∀ i → V i ∈ √ (fst I)) ltrImpl √⟨V⟩⊆√I i = √⟨V⟩⊆√I _ (∈→∈√ (fst ⟨ V ⟩[ R' ]) (V i) ∣ (λ j → δ i j) , sym (∑Mul1r _ _ i) ∣) rtlImpl : (∀ i → V i ∈ √ (fst I)) → √ (fst ⟨ V ⟩[ R' ]) ⊆ √ (fst I) rtlImpl ∀i→Vi∈√I x = PT.elim (λ _ → √ (fst I) x .snd) λ { (n , xⁿ∈⟨V⟩) → ^∈√→∈√ (fst I) x n (elimHelper _ xⁿ∈⟨V⟩) } where isCommIdeal√I = √OfIdealIsIdeal (fst I) (snd I) elimHelper : ∀ (y : R) → y ∈ (fst ⟨ V ⟩[ R' ]) → y ∈ √ (fst I) elimHelper y = PT.elim (λ _ → √ (fst I) y .snd) λ { (α , y≡∑αV) → subst-∈ (√ (fst I)) (sym y≡∑αV) (∑Closed R' (√ (fst I) , isCommIdeal√I) (λ i → α i · V i) (λ i → isCommIdeal√I .·Closed (α i) (∀i→Vi∈√I i))) }
### A Pluto.jl notebook ### # v0.17.3 using Markdown using InteractiveUtils # This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). macro bind(def, element) quote local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end local el = $(esc(element)) global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el) el end end # ╔═╡ 48c789c8-214e-11eb-0c42-c90206ac9147 # Boilerplate code to pull in required packages in a portable way begin import Pkg Pkg.activate(Base.current_project()) using Plots using ERFA using LinearAlgebra # for dot product md"# Phased Array Beam Patterns This notebook develops a beam pattern analysis for phased arrays of homogenous radio telescopes. " end # ╔═╡ fa66394c-21a1-11eb-1991-fb0fb1181350 md"""## Introduction""" # ╔═╡ dc0d7392-2175-11eb-0964-5b252639b5fd md"""For steerable radio telecscope arrays, the array's _control system_ directs the antennas' drive systems to orient the antennas' parabolic reflectors such that the center of each of antenna's primary beam is aligned with the location specified by the observer's instructions. This location is referred to as the _pointing center_. Typically, the pointing center is continuously updated to _track_ the apparent location of a celestial source (i.e. object or location) as it moves across the sky. Most steerable radio telescopes have _altitude-azimuth_ (or _Alt-Az_) drive systems that are steerable in azimuth and elevation (aka altitude). Some have equitorial (aka polar) drive systems that are steerable in hour angle and declination. In either case, the phased array beam analysis is similar. Non-steerable radio telescopes rely on the apparent motion of sources across the sky (e.g. due to the rotation of Earth) to allow observation of multiple pointing centers. Many of the phased array concepts presented here are relevant for non-steerable readio telescopes as well, but non-steerable radio telescopes often have non-circular primary beam patterns which can complicate such analysis. The anaysis presented here is for a radio telescope array whose antennas have a circular primary beam, though the concepts should apply to non-circular primary beams as well. This analysis also assumes that the radio telescopes are steerable in azimuth and elevation, but the end result is basically the same regardless of the type of drive system. """ # ╔═╡ b2c21684-21a5-11eb-0d02-853dfc69164c md"## Phased Array Theory of Operation" # ╔═╡ ceed38a2-231f-11eb-1f9a-cf730d080095 md"""The voltage produced by each radio telescope is proportional to the sum of the radio frequency energies emitted by the all the sources within the primary beam (and sidelobes) plus the uncorrelated system noise of the antenna and signal path.""" # ╔═╡ 7f734cbc-219b-11eb-1471-594ab489e084 md"When operating in _phased array_ mode, the voltages from the antennas are aligned in both time and phase relative to a desired sky position and the array's reference position. This desired sky position is known as the _phase center_. Although not strictly required, the phase center is almost always located within the primary beam. When the phase center happens to be the same as the pointing center (i.e. the center of the primary beam), the array is said to be _phased to boresight_. " # ╔═╡ fd656238-2176-11eb-3a4e-7dbd106b836b md"""The time and phase aligned signals from all the antennas are then added together to produce a _phased array sum_ (aka _coherent beam_). This results in _constructive interference_ at the phase center where the correlated energy (i.e. the energy from celestial sources, not the energy from system noise) from the antennas add together in-phase for maximum gain while the uncorrelated energy (aka system noise) adds together randomly and the correalted energy from elsewhere in the primary beam adds together with sub-optimal phasing that varies across the primary beam. Determining how much gain each primary beam location experiences due to summing is the main objective of the phased array beam pattern analysis. The time alignemnt depends on the _geometric delays_ from the antennas to the array reference location as the RF wavefront propgates across the array. These geometric delays differ depending on phase center location and array geometry. The signal from each antenna also experiences a finite _fixed delay_ that generally differs between antennas (e.g. due to cable length variations). The geometric delays vary as the phase center moves relative to the array whereas the fixed delays, as their name implies, do not generally vary. Geometric delays can be calculated when the phase center and array geometry are known, but fixed delays must be measured in situ or given _a priori_. Other delays, such as those induced by atmosphereic variations over the array, can further complicate things but this analysis will ignore these other sources of delay and delay variation. Once the geometric and fixed delays are known and compensated for, the signals must still be phase aligned before they will add contructively. The signal from an antenna can be delay corrected for a single delay value only. This delay value is the geometric delay for the _delay center_ (generally the same location as the phase center) plus the antenna's fixed delay. Delay corrections are generally performed in discrete steps, which means that there is usually a small residual delay that remains uncorrected. Phase is the product of frequency and time, ``\phi = \omega \tau``, so the residual delay (a time offset) results in a frequency dependent phase offset. This phase offset can be removed on a per channel basis after the signal has been channelized into multiple frequency components (e.g. by an FFT or PFB). Locations other than the delay center also have their own residual delays that vary depending on their relationship to the delay center. Additionally, each antenna has a unique instrumental phase that results from many different factors and must be measured in situ. Determination of the instrumental phases is beyond the scope of this analysis, so we assume here that the intrumental phases are zero or have already been corrected for. """ # ╔═╡ e7853568-21a5-11eb-13de-f17b68612831 md"""Phasing the antennas to a specific phase center requires determination of the geometric delays. The concept for this is relatively straightforard. The geometric delay is proportional to the geometric distance that the planar wavefront travels from antenna to array reference location. This distance is the projection of the baseline vector ``\mathbf{b}``, defined to be the vector from the array reference position to the antenna position, onto the unit vector ``\hat{s}``, which points in the direction of the delay center from the array reference position. This can be computed by taking the dot product of ``\mathbf{b}`` and ``\hat{s}``, which is written as ``\mathbf{b}\cdot\hat{s}``. The array reference position is usually treated as the origin of the array reference frame so the baseline vector ``\mathbf{b}`` is the same as the antenna position in the array reference frame. To take the dot product, both ``\mathbf{b}`` and ``\hat{s}`` must be represented in the same frame.""" # ╔═╡ 190282de-21a2-11eb-176e-178fd029cb6d md"""## Primary Beam Coordinates""" # ╔═╡ c2295c46-219f-11eb-2d92-cfdeba1d942d md"""The analysis starts by exploring the coordinates of various points within the primary beam of the relescope. The primary beam is modeled as a circle with an angular diameter equal to the full width half maximum (FWHM) of a single radio telescope. For convenience, this circle is inscribed in a square region of sky which is represented by a two dimensional grid of points with the central point corresponding to the center of the primary beam, i.e. the pointing center. To keep things simple (or at least less complicated), this analysis uses a _flat sky_ approximation. """ # ╔═╡ 54a02260-219d-11eb-17b6-17b0e0bc9d8d md"The axes of this grid correspond to cross-elevation (horizontal, aka `xel`) and elevation (vertical, aka `el`) as seen from the telescope's perspective. The origin of the grid is the center of the primary beam. The unit steps in the cross-elevation and elevations directions are `dxel` and `del`, respectively, though they are sometimes shortened here to `dx` and `de`. The coordinate frame of this grid is referred to here as the _primary beam frame_. A primary beam with FWHM of 2 (arbitrary angular units) and `dxel`, `del` values of 0.25 (arbitrary angular units) can depicted as: " # ╔═╡ bc7cb314-2150-11eb-2900-9b1c7ab0a8d9 begin plot(cos, sin, 0:0.01:2π, aspect_ratio=:equal, legend=false, xflip=true) scatter!(vec([(x,y) for y=-1:0.25:1, x=-1:0.25:1]), ms=2) title!("Primary Beam") xlabel!("Cross Elevation (dxel=0.25)") ylabel!("Relative Elevation (del=0.25)") end # ╔═╡ 2f22727e-22ef-11eb-379f-fd85d1a81d55 md"""For reasons that will be clear later, we have opted to orient the cross elevation (horizontal) axis with poitive values to the left of the origin and negative values to the right.""" # ╔═╡ a018417a-2227-11eb-2f6d-b7460d2e140d md"""After compensating for geometric delay at the delay center, the residual delay at the delay center is zero. The rest of the antenna's primary beam will have a delay gradient that depends on the geometry of the delay center relative to the antenna location and array reference location. To compute the delay for a given point, we must create a unit vector, ``\hat{s}``, in the direction of the point and take the dot product of that and the baseline vector ``\mathbf{b}``. We are free to choose the coordinate frame in which ``\hat{s}`` is represented. Usually that frame will be different from the frame in which the antenna positions are expressed, so before taking the dot product we need to ensure we convert the antenna positions into the frame of ``\hat{s}`` or vice versa. For beam pattern analysis we will typically have more ``\hat{s}`` vectors than antennas, so it will be more efficient to transform the antenna positions into the frame of the ``\hat{s}`` vectors.""" # ╔═╡ 9eb14aca-2323-11eb-3543-33f08ff00e2c md"""As described above, the coordinate frame for ``\hat{s}`` is most naturally expressed in terms of spherical coordintates of ``(\theta, \phi, 1)``, where ``\theta`` is ``\sphericalangle xel``, ``\phi`` is ``\sphericalangle el``, and ``1`` is the unit length of ``\hat{s}``. The ``\hat{s}`` vector needs to be expressed in a rectalinear form so that we can take the dot product with rectalinear baseline vector ``\mathbf{b}``. The rectalinear form of ``\hat{s}`` is also known as _direction cosines_. The ERFA library we are using provides a spherical to Cartesian function, ``\mathtt{s2c}(θ,ϕ)``, that we can use to calculate ``\hat{s}`` for any values of `xel` and `el`. Here is how to calculate ``\hat{s}`` for the pointing center and two other points (one on each axis):""" # ╔═╡ 5b49716c-2327-11eb-2df4-37ceb3707973 begin dxel = 0.25 * ERFA.DD2R del = 0.25 * ERFA.DD2R [ERFA.s2c(θ, ϕ) for (θ, ϕ) in [(0,0), (dxel,0), (0,del)]] end # ╔═╡ a85178f6-2327-11eb-2535-c1f23b6a5484 md"""As you can see, `s2c()` takes two angles (NB: in radians) and returns a rectalinear vector that, in our case, corresponds to `(s, xel, el)`, where `s` is the direction of the source (away from the viewer), `xel` is the cross elevation direction, and `el` is the elevation direction. We choose `xel` to be positive to the left of the origin and `el` positive above the origin to make this a right-handed system because the antenna positions are also specified in a right handed system.""" # ╔═╡ a0fd25d6-2335-11eb-223d-fb1a8be4a076 md"""## Antenna Position Coordinates""" # ╔═╡ ac2e3c86-222b-11eb-0297-f1aa2b01b60d md"""Antenna positions are often represented in a topocentric (East, North, Up) or ENU frame, which is a right-handed system. Antenna positions can also be represented in an _Earth Centered Earth Fixed_ (ECEF) frame known as the _International Terrestrial Reference Frame_ (ITRF). The ECEF frame can be converted to the ENU frame used in the analysis here, so we will not treat it separately. Antenna positions are usually given in meters, but other units are sometimes used as well (e.g. nanoseconds or wavelengths at a given frequency). For our purposes, we will ultimately need to convert the units to time and/or a frequency dependent phase.""" # ╔═╡ 5493615c-2336-11eb-2c36-0772eadafb39 md"""## Coordinate Frame Transformations""" # ╔═╡ 396e99c8-2336-11eb-24a9-fddf80b160b5 md"""The (s, xel, el) primary beam frame described above is beam-centric in that it does not depend on the location of the pointing center on the sky. On the other hand, the transformation from the topocentric ENU frame to the beam-centric (s, xel, el) frame does depend on the location of the pointing center.""" # ╔═╡ ff98a0d8-2252-11eb-1056-59c804698c62 md"""The transformation from the ENU frame to the (s, xel, el) frame can be represented as a series of two rotations around various axes of the frame iteslf. Transforming from the ENU frame to the (s, xel, el) frame can be performed by: 1. Rotating the (E,N,U) frame around the U (Up) axis in the clockwise direction (as viewed looking down to the origin) by the topocentric azimuth angle of the pointing center minus 90 degrees. This results in an intermediate (E',N',U) frame. 2. Rotating the intermediate (E',N',U) frame around the N' axis in the clockwise direction (as viewed looking at the origin from positive N') by the elevation angle. This results in a (E", N', U') frame that is equivalent to the (s, xel, el) frame in which our ``\hat{s}`` vectors are expressed. """ # ╔═╡ f4f6ab3a-222c-11eb-0564-17ceb3dde858 md"""Each of these rotations can be represented by a 3x3 rotation matrix. These matices can be multiplied together, in the proper order, to produce a single composite 3x3 rotation matrix that transforms the ENU frame into the beam-centric (s, xel, el) frame for the azimuth and elevation of a given the pointing center. The ENU antenna position(s) represented as a 3 element column vector (or 3xM matrix of M antenna positions) can be left multiplied by this composite rotation matrix to produce the antenna position(s) in the (s, xel, el) frame. Here we define an `enu2beam(az, el)` function that returns this composite rotation matrix for a pointing center at azimuth `az` and elevation `el` (both given in degrees):""" # ╔═╡ 57172622-2325-11eb-21f5-87aba95fac55 begin """ Return a 3x3 rotation matrix for ENU to beam transformation for the pointing center at azimuth `az` and elevation `el` (both given in degrees). """ function enu2beam(az, el) ERFA.ry(-el*ERFA.DD2R, ERFA.rz(π/2 - az*ERFA.DD2R, [1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0] ) ) end # Version that takes a Tuple and auto-splats it enu2beam(azel::Tuple{Real, Real}) = enu2beam(azel...) end # ╔═╡ 610ca96c-2330-11eb-1869-593e53e74f42 md"""Let's try it out on some basic test cases!""" # ╔═╡ 6096037a-2330-11eb-1e75-c360e0e0c494 enu2beam(0, 0) # north horizon # ╔═╡ 76617054-2332-11eb-15f1-91a9f5207081 enu2beam(90, 0) # east horizon # ╔═╡ 440f67c2-2333-11eb-0975-f362da0edde5 enu2beam(0, 90) # zenith from north # ╔═╡ b26834ae-2333-11eb-13da-7d924b886cec enu2beam(180, 90) # zenith from south # ╔═╡ e902f9fe-2333-11eb-0bb5-9949d2f05225 md"""Notice that in the last example (zenith from south), the sign of `xel` and `el` will be opposite from the example that preceeds it (zenith from north) even though both have the local zenith as the pointing center.""" # ╔═╡ e8db8432-2333-11eb-3195-877803e736ba md"""## Putting It All Together""" # ╔═╡ e8b55f50-2333-11eb-0f6c-abc07cdfd3cc md"""We now have the tools to start building and putting together all the various parts of the analysis: - Grid of points covering the primary beam - Unit ``\hat{s}`` vectors for each of those points - Antenna positions in ENU form - Conversion from ENU frame to beam frame for arbitrary pointing center - Dot product to compute distance/delay from antenna to array reference poistion """ # ╔═╡ d620f9aa-23ba-11eb-11a2-75d99569a381 md"""Here we create a grid of points to cover the primary beam and unit ``\hat{s}`` vectors corresponding to those points:""" # ╔═╡ 165f5502-23b6-11eb-3824-dde609547349 npoints = 65 # ╔═╡ 5a17d3a8-23b6-11eb-278f-0f399b01b6b1 fwhm = 2.0 # ╔═╡ 11735a72-23b7-11eb-0c75-39f94e10ba04 xels = range(-fwhm/2, +fwhm/2, length=npoints) # ╔═╡ 4697cad0-23b7-11eb-17fd-d73044fab8bb els = range(-fwhm/2, +fwhm/2, length=npoints) # ╔═╡ 7ba15bf6-23b7-11eb-3355-9932eae00a13 grid_coords = collect(Iterators.product(xels, els)) # ╔═╡ a121be52-23b7-11eb-3fa0-f7b7cef14f66 # We could also define an `ERFA.s2c(t::Tuple)` method and # use broadcasting, but using `map()` is good enough for now. grid_svecs = map(p->ERFA.s2c((p.*ERFA.DD2R)...), grid_coords) # ╔═╡ babfe764-23ba-11eb-02a2-714e5c641733 md"""We start with one antenna which you are free to move around (up to 1 km in each direction): $(@bind user_east html"<input type=range min=-100000 max=100000 value=3000 style='width: 75%'> East</br>") $(@bind user_north html"<input type=range min=-100000 max=100000 value=0 style='width: 75%'> North</br>") $(@bind user_up html"<input type=range min=-100000 max=100000 value=0 style='width: 75%'> Up") """ # ╔═╡ bf0e1a08-23e1-11eb-22e3-2f9770941b9f user_antpos_enu = [user_east, user_north, user_up] ./ 100 # ╔═╡ 34d02b10-23e1-11eb-1ef6-3540d2475004 md"""And of course you get to point the antenna too: $(@bind user_az html"<input type=range min=0 max=359 value=90 style='width: 75%'> Azimuth</br>") $(@bind user_el html"<input type=range min=0 max=90 value=0 style='width: 75%'> Elevation") """ # ╔═╡ ba454464-23ba-11eb-08f7-bb9bd85194e8 user_pointing_azel = (user_az, user_el) # ╔═╡ 62a0f894-23d7-11eb-347f-c3c1de1f41a8 md"""Now we can transform your specified (E, N, U) antenna position from the ENU frame to the (s, xel, el) frame of your specified (az, el) pointing center.""" # ╔═╡ 18d78b34-23d6-11eb-33f1-8df5a4066d65 user_enu2beam = enu2beam(user_pointing_azel) # ╔═╡ e899c044-23d6-11eb-2780-a1fe38bec119 user_antpos_pointing = user_enu2beam * user_antpos_enu # ╔═╡ ece4a6b8-23c3-11eb-38e7-bd248d0f0bc5 md"""With the antenna position in the same frame as the unit ``\hat{s}`` vectors, we can take the dot products to calculate the distances from the antenna to the array reference position (i.e. the origin of the ENU frame) for each point in the primary beam. We are more interested in the relative distances across the beam rather than the absoulte distances. To calculate the relative distances we subtract each unit vector ``\hat{s}`` from unit vector ``\hat{d}`` that points in the direction of the delay center (assumed here to be the same as the pointing center). These relative distances can be plotted as a contour plot. """ # ╔═╡ a2bf4b28-23d5-11eb-1ef1-1170b39fcb9e reldists = map(s->dot(ERFA.s2c(0,0)-s, user_antpos_pointing), grid_svecs); # ╔═╡ 601ffcd6-23c4-11eb-2012-01bb72855b38 contour(xels, els, reldists', aspect_ratio=:equal, fill=true, clabels=true, fillcolor=:lightrainbow, linecolor=:black, title="Antenna to Origin: Distance\nrelative to (az=$(user_az), el=$(user_el))", xlabel="Cross Elevation (degrees)", ylabel="Elevation (degrees)" ) # ╔═╡ a37ac5d2-2483-11eb-3761-c18b249d25c1 md"""For a given frequency, these relative distances can be converted to relative phases which can also be plotted as a heapmap plot: $(@bind user_mhz html"<input type=range min=500 max=2000 value=1420 style='width: 75%'> Frequency (MHz)") """ # ╔═╡ af50e5c2-2487-11eb-1da9-add2857380a8 md"""Frequency: $(user_mhz) MHz""" # ╔═╡ 13c703ec-2488-11eb-06e2-a93d6fc4ada1 begin # ERFA.CMPS is speed of light in meters per second λ = ERFA.CMPS / user_mhz / 1e6 relphases = rem2pi.(2π .* reldists ./ λ, RoundNearest) .* ERFA.DR2D end; # ╔═╡ de5be0d6-2489-11eb-21b1-e3218333e30d begin plt=heatmap(xels, els, relphases', aspect_ratio=:equal, color=:hsv, clims=(-180,180), levels=71, title="Antenna to Origin: Degrees of Phase\nrelative to az=$(user_az), el=$(user_el) at $(user_mhz) MHz (λ=$(round(1e5λ)/1e3) cm)\n", xlabel="Cross Elevation (degrees)", ylabel="Elevation (degrees)" ) # Plot 5 degree contours if pases are within +/- 90 degrees # (contouring around phase wraps gets ugly) if maximum(abs.(relphases)) <= 90 contour!(xels, els, relphases', aspect_ratio=:equal, fill=false, clabels=true, levels=71, linecolor=:black, colorbar_entry=false ) end plt end # ╔═╡ 7324d316-24ae-11eb-2112-a51606afab74 if maximum(abs.(relphases)) <= 90 md"""(Phases within ±90 degrees: Showing 5 degree contour lines.)""" else md"""(Phases greater than ±90 degrees: Contour lines are not being shown.)""" end # ╔═╡ 22338236-24b3-11eb-02aa-0bc76375dfd3 md"""## Adding a Second Antenna""" # ╔═╡ 4196dd3a-24b3-11eb-2e0d-650a39dc4bb6 md"""Now that we can compute phases across the primary beam of an antenna relative to the array center for a given pointing/delay center at a given frequency, the next thing to do is add another antenna. With two antennas, we can delay correct them for a common delay/pointing center, calcluate their phases across the primary beam, convert these phases to unit vectors in the complex plane (i.e. complex numbers), and add corresponding complex numbers together to create the complex beam pattern of the coeherent beam created by adding the two delay corrected signals together.""" # ╔═╡ aef63f92-24b3-11eb-1a6c-79b47130a4a9 md"""To keep the UI simple, we will use new antennas, new pointing center, and new frequency. The new antennas will have an `Up` coordinate of zero, but you can still move them East/West and North/South.""" # ╔═╡ dc9d05c2-24b8-11eb-0ec2-87d8c461845a md""" $(@bind ant1_east html"<input type=range min=-100000 max=100000 value=3000 style='width: 75%'> Ant 1 East</br>") $(@bind ant1_north html"<input type=range min=-100000 max=100000 value=0 style='width: 75%'> Ant 1 North</br>") $(@bind ant2_east html"<input type=range min=-100000 max=100000 value=0 style='width: 75%'> Ant 2 East</br>") $(@bind ant2_north html"<input type=range min=-100000 max=100000 value=3000 style='width: 75%'> Ant 2 North</br>") $(@bind ant12_az html"<input type=range min=0 max=359 value=90 style='width: 75%'> Ants 1,2 Azimuth</br>") $(@bind ant12_el html"<input type=range min=0 max=90 value=0 style='width: 75%'> Ants 1,2 Elevation") $(@bind ant12_mhz html"<input type=range min=500 max=2000 value=1420 style='width: 75%'> Ants 1,2 Frequency") """ # ╔═╡ 15fea64e-24ba-11eb-09cf-4d47980c7fb5 begin ant12_enu2beam = enu2beam(ant12_az, ant12_el) ant1_antpos_pointing = ant12_enu2beam * [ant1_east, ant1_north, 0] ./ 100 ant2_antpos_pointing = ant12_enu2beam * [ant2_east, ant2_north, 0] ./ 100 ant1_reldists = map(s->dot(ERFA.s2c(0,0)-s, ant1_antpos_pointing), grid_svecs) ant2_reldists = map(s->dot(ERFA.s2c(0,0)-s, ant2_antpos_pointing), grid_svecs) λ12 = ERFA.CMPS / ant12_mhz / 1e6 ant1_relphases = rem2pi.(2π .* ant1_reldists ./ λ12, RoundNearest) ant2_relphases = rem2pi.(2π .* ant2_reldists ./ λ12, RoundNearest) #ant1_relphases = 2π .* ant1_reldists ./ λ12 #ant2_relphases = 2π .* ant2_reldists ./ λ12 ant1z = exp.(1im*ant1_relphases) ant2z = exp.(1im*ant2_relphases) ant12z = ant1z .+ ant2z p1=heatmap(xels, els, ant1_relphases' .* ERFA.DR2D, aspect_ratio=:equal, color=:hsv, clims=(-180,180), levels=71, title="Ant 1 Phases", #xlabel="Cross Elevation (degrees)", #ylabel="Elevation (degrees)" ) p2=heatmap(xels, els, ant2_relphases' .* ERFA.DR2D, aspect_ratio=:equal, color=:hsv, clims=(-180,180), levels=71, title="Ant 2 Phases", #xlabel="Cross Elevation (degrees)", #ylabel="Elevation (degrees)" ) p3=heatmap(xels, els, abs.(ant12z)', aspect_ratio=:equal, fill=true, fillcolor=:thermal, climes=(0,2), levels=9, title="Coherent Beam (amplitude)" ) p4=heatmap(xels, els, angle.(ant12z)' .* ERFA.DR2D, aspect_ratio=:equal, color=:hsv, clims=(-180,180), levels=71, title="Coherent Beam (phase)" ) plot(p1, p2, p3, p4) end # ╔═╡ 63963368-24bf-11eb-1237-773f333dcb96 ant1_enu = [ant1_east, ant1_north, 0] ./ 100 # ╔═╡ d853dd02-24bf-11eb-11f2-6d197e32c0c3 ant2_enu = [ant2_east, ant2_north, 0] ./ 100 # ╔═╡ e41097de-24bf-11eb-2fed-a527d5c53dbe ant12_azel = (ant12_az, ant12_el) # ╔═╡ 07431902-24c0-11eb-2f8c-07c42874be62 ant12_freq_mhz = ant12_mhz # ╔═╡ b9e16b1a-23ba-11eb-08ad-8fc21f98dca9 md"""---""" # ╔═╡ 3beff902-225b-11eb-267d-21ef072bf855 ant1_reldists # ╔═╡ 428408b8-2151-11eb-0530-d1996a93b332 # ╔═╡ 3e4354d4-2151-11eb-384f-7706d85ce220 # ╔═╡ bccfe344-214c-11eb-2a1a-ff912a978a1e # ╔═╡ Cell order: # ╟─48c789c8-214e-11eb-0c42-c90206ac9147 # ╟─fa66394c-21a1-11eb-1991-fb0fb1181350 # ╟─dc0d7392-2175-11eb-0964-5b252639b5fd # ╟─b2c21684-21a5-11eb-0d02-853dfc69164c # ╟─ceed38a2-231f-11eb-1f9a-cf730d080095 # ╟─7f734cbc-219b-11eb-1471-594ab489e084 # ╟─fd656238-2176-11eb-3a4e-7dbd106b836b # ╟─e7853568-21a5-11eb-13de-f17b68612831 # ╟─190282de-21a2-11eb-176e-178fd029cb6d # ╟─c2295c46-219f-11eb-2d92-cfdeba1d942d # ╟─54a02260-219d-11eb-17b6-17b0e0bc9d8d # ╟─bc7cb314-2150-11eb-2900-9b1c7ab0a8d9 # ╟─2f22727e-22ef-11eb-379f-fd85d1a81d55 # ╟─a018417a-2227-11eb-2f6d-b7460d2e140d # ╟─9eb14aca-2323-11eb-3543-33f08ff00e2c # ╠═5b49716c-2327-11eb-2df4-37ceb3707973 # ╟─a85178f6-2327-11eb-2535-c1f23b6a5484 # ╟─a0fd25d6-2335-11eb-223d-fb1a8be4a076 # ╟─ac2e3c86-222b-11eb-0297-f1aa2b01b60d # ╟─5493615c-2336-11eb-2c36-0772eadafb39 # ╟─396e99c8-2336-11eb-24a9-fddf80b160b5 # ╟─ff98a0d8-2252-11eb-1056-59c804698c62 # ╟─f4f6ab3a-222c-11eb-0564-17ceb3dde858 # ╠═57172622-2325-11eb-21f5-87aba95fac55 # ╟─610ca96c-2330-11eb-1869-593e53e74f42 # ╠═6096037a-2330-11eb-1e75-c360e0e0c494 # ╠═76617054-2332-11eb-15f1-91a9f5207081 # ╠═440f67c2-2333-11eb-0975-f362da0edde5 # ╠═b26834ae-2333-11eb-13da-7d924b886cec # ╟─e902f9fe-2333-11eb-0bb5-9949d2f05225 # ╟─e8db8432-2333-11eb-3195-877803e736ba # ╟─e8b55f50-2333-11eb-0f6c-abc07cdfd3cc # ╟─d620f9aa-23ba-11eb-11a2-75d99569a381 # ╟─165f5502-23b6-11eb-3824-dde609547349 # ╟─5a17d3a8-23b6-11eb-278f-0f399b01b6b1 # ╠═11735a72-23b7-11eb-0c75-39f94e10ba04 # ╠═4697cad0-23b7-11eb-17fd-d73044fab8bb # ╠═7ba15bf6-23b7-11eb-3355-9932eae00a13 # ╠═a121be52-23b7-11eb-3fa0-f7b7cef14f66 # ╟─babfe764-23ba-11eb-02a2-714e5c641733 # ╟─bf0e1a08-23e1-11eb-22e3-2f9770941b9f # ╟─34d02b10-23e1-11eb-1ef6-3540d2475004 # ╟─ba454464-23ba-11eb-08f7-bb9bd85194e8 # ╟─62a0f894-23d7-11eb-347f-c3c1de1f41a8 # ╠═18d78b34-23d6-11eb-33f1-8df5a4066d65 # ╠═e899c044-23d6-11eb-2780-a1fe38bec119 # ╟─ece4a6b8-23c3-11eb-38e7-bd248d0f0bc5 # ╠═a2bf4b28-23d5-11eb-1ef1-1170b39fcb9e # ╟─601ffcd6-23c4-11eb-2012-01bb72855b38 # ╟─a37ac5d2-2483-11eb-3761-c18b249d25c1 # ╟─af50e5c2-2487-11eb-1da9-add2857380a8 # ╠═13c703ec-2488-11eb-06e2-a93d6fc4ada1 # ╠═de5be0d6-2489-11eb-21b1-e3218333e30d # ╟─7324d316-24ae-11eb-2112-a51606afab74 # ╟─22338236-24b3-11eb-02aa-0bc76375dfd3 # ╟─4196dd3a-24b3-11eb-2e0d-650a39dc4bb6 # ╟─aef63f92-24b3-11eb-1a6c-79b47130a4a9 # ╟─dc9d05c2-24b8-11eb-0ec2-87d8c461845a # ╟─15fea64e-24ba-11eb-09cf-4d47980c7fb5 # ╟─63963368-24bf-11eb-1237-773f333dcb96 # ╟─d853dd02-24bf-11eb-11f2-6d197e32c0c3 # ╟─e41097de-24bf-11eb-2fed-a527d5c53dbe # ╟─07431902-24c0-11eb-2f8c-07c42874be62 # ╠═b9e16b1a-23ba-11eb-08ad-8fc21f98dca9 # ╠═3beff902-225b-11eb-267d-21ef072bf855 # ╠═428408b8-2151-11eb-0530-d1996a93b332 # ╠═3e4354d4-2151-11eb-384f-7706d85ce220 # ╠═bccfe344-214c-11eb-2a1a-ff912a978a1e
% ----------------------------------------------------------------------------- % Author : Bimalka Piyaruwan Thalagala % GitHub : https://github.com/bimalka98 % Date Created : 01.09.2020 % Last Modified : 01.03.2020 % ----------------------------------------------------------------------------- \documentclass[a4paper,10pt]{article}%,twocolumn \input{settings/packages} \input{settings/page} \input{settings/jupyter} \begin{document} \input{content/title_page} \tableofcontents \begin{center} \textbf{\textit{* PDF is clickable}}\\ \end{center} Without the title page and the content table page there are only 6 pages in this Assignments. Only the important parts of the codes are given here due to page limitation. Complete executable code can be found at \url{https://github.com/bimalka98/Computer-Vision-and-Image-Processing/blob/main/EN2550Assignments/A1/180631J_a01.ipynb} \pagebreak \section{Part 1: Basic Operations} \subsection{Histogram computation and Histogram equalization} Histogram of an image represents the intensity distribution(\textit{intensity vs number of pixels}) over the intensities[0, 255]. Histogram equalization makes uneven histograms more or less flat. Figure (b) depicts the uneven histogram of the original image. There, most of the red pixels are in the right region(\textit{biased to the right}) which makes the original image looks more reddish than natural. Through histogram equalization as depicted in the figure (d) the distribution can be made more uniform and it has given the image a more natural look. \begin{figure}[!h] \centering \subfigure[Original Image] { \includegraphics[scale=0.2]{figures/img0} } \subfigure[Hist: of the Original Image] { \includegraphics[scale=0.2]{figures/hiscomp} } \subfigure[Hist: Equalized Image] { \includegraphics[scale=0.2]{figures/equalized_img} } \subfigure[Equalized Histogram] { \includegraphics[scale=0.2]{figures/hisequ} } \caption{Histogram computation and Histogram equalization} \end{figure} \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{1}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{n}{channels} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{b}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{g}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{r}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}\PY{c+c1}{\PYZsh{} since opencv reads img as BGR channel order} \PY{k}{for} \PY{n}{i}\PY{p}{,} \PY{n}{channel} \PY{o+ow}{in} \PY{n+nb}{enumerate}\PY{p}{(}\PY{n}{channels}\PY{p}{)}\PY{p}{:} \PY{n}{histogram} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{calcHist}\PY{p}{(}\PY{p}{[}\PY{n}{img}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{n}{i}\PY{p}{]}\PY{p}{,} \PY{k+kc}{None}\PY{p}{,} \PY{p}{[}\PY{l+m+mi}{256}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{l+m+mi}{0}\PY{p}{,}\PY{l+m+mi}{256}\PY{p}{]}\PY{p}{)}\PY{c+c1}{\PYZsh{} Calculating Histogram of each channel.} \PY{n}{equalized\PYZus{}channels} \PY{o}{=} \PY{p}{[}\PY{p}{]} \PY{k}{for} \PY{n}{channel} \PY{o+ow}{in} \PY{n}{cv}\PY{o}{.}\PY{n}{split}\PY{p}{(}\PY{n}{img}\PY{p}{)}\PY{p}{:} \PY{n}{equalized\PYZus{}channels}\PY{o}{.}\PY{n}{append}\PY{p}{(}\PY{n}{cv}\PY{o}{.}\PY{n}{equalizeHist}\PY{p}{(}\PY{n}{channel}\PY{p}{)}\PY{p}{)}\PY{c+c1}{\PYZsh{} Each channel must be equalized seperately.} \PY{n}{equalized\PYZus{}img} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{merge}\PY{p}{(}\PY{n}{equalized\PYZus{}channels}\PY{p}{)} \end{Verbatim} \end{tcolorbox} \subsection{Intensity transformations} Intensity transformations is basically a look up table operation. It maps each pixel's intensity to some other intensity depending on a predefined transformation function which only depends on the pixel of interest. Following figures illustrates a transformation consists of three sections(\textit{piece-wise continuous function}). It maps intensities in the ranges [0, 99],[100, 129] and [130, 255] into the ranges [0, 40], [41, 200] and [201, 255] respectively as shown in the transformation function. This kind of transformation is called as \textbf{\textit{Intensity windowing.}} \begin{figure}[!h] \centering \subfigure[Original Image] { \includegraphics[scale=0.2]{figures/boriginal} } \subfigure[Transformation] { \includegraphics[scale=0.4]{figures/transformation} } \subfigure[Transformed Image] { \includegraphics[scale=0.2]{figures/btransformed} } \caption{Intensity transformations} \end{figure} \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{2}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{n}{a}\PY{p}{,} \PY{n}{b} \PY{o}{=} \PY{p}{[}\PY{l+m+mi}{40}\PY{p}{,}\PY{l+m+mi}{200}\PY{p}{]} \PY{n}{tr1} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,}\PY{n}{a}\PY{p}{,}\PY{l+m+mi}{100}\PY{p}{)}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{uint8}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{c+c1}{\PYZsh{} Declaring tranformations for each region} \PY{n}{tr2} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{n}{a}\PY{o}{+}\PY{l+m+mi}{1}\PY{p}{,}\PY{n}{b}\PY{p}{,}\PY{l+m+mi}{30}\PY{p}{)}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{uint8}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{n}{tr3} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{linspace}\PY{p}{(}\PY{n}{b}\PY{o}{+}\PY{l+m+mi}{1}\PY{p}{,}\PY{l+m+mi}{255}\PY{p}{,}\PY{l+m+mi}{126}\PY{p}{)}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{uint8}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{n}{transf} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{concatenate}\PY{p}{(}\PY{p}{(}\PY{n}{tr1}\PY{p}{,} \PY{n}{tr2}\PY{p}{)}\PY{p}{,} \PY{n}{axis} \PY{o}{=} \PY{l+m+mi}{0}\PY{p}{)}\PY{c+c1}{\PYZsh{} Concatenating above transfer functions} \PY{n}{transf} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{concatenate}\PY{p}{(}\PY{p}{(}\PY{n}{transf}\PY{p}{,} \PY{n}{tr3}\PY{p}{)}\PY{p}{,} \PY{n}{axis} \PY{o}{=} \PY{l+m+mi}{0}\PY{p}{)} \PY{n}{transformed\PYZus{}img} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{LUT}\PY{p}{(}\PY{n}{img}\PY{p}{,} \PY{n}{transf}\PY{p}{)}\PY{c+c1}{\PYZsh{} Apply Transformation} \end{Verbatim} \end{tcolorbox} \subsection{Gamma correction} Image transformation Depends on the value of $\gamma$ as follows, \begin{itemize} \item If $0< \gamma <1$, then function maps narrow range of dark pixels to a wider range of dark pixels which increases the brightness of the image as depicted in figures (c) and (d). \item If $\gamma >1$, then opposite of the above process happens and it makes the image darker as in the figure (a). \end{itemize} \begin{figure}[!h] \centering \subfigure[Gamma Corrected Image $\gamma = 1.3$] { \includegraphics[scale=0.2]{figures/dgamma3} } \subfigure[Original Image $\gamma = 1$] { \includegraphics[scale=0.2]{figures/doriginal} } \subfigure[Gamma Corrected Image $\gamma = 0.7$] { \includegraphics[scale=0.2]{figures/dgamma7} } \subfigure[Gamma Corrected Image $\gamma = 0.4$] { \includegraphics[scale=0.2]{figures/dgamma4} } \caption{Gamma correction} \end{figure} \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{3}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{k}{def} \PY{n+nf}{gammacorrect}\PY{p}{(}\PY{n}{image}\PY{p}{,} \PY{n}{gamma}\PY{p}{)}\PY{p}{:} \PY{c+c1}{\PYZsh{} Calculating the lookup table for a given gamma value.} \PY{n}{table} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{array}\PY{p}{(}\PY{p}{[}\PY{p}{(}\PY{n}{i}\PY{o}{/}\PY{l+m+mf}{255.0}\PY{p}{)}\PY{o}{*}\PY{o}{*}\PY{p}{(}\PY{n}{gamma}\PY{p}{)}\PY{o}{*}\PY{l+m+mf}{255.0} \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{l+m+mi}{0}\PY{p}{,}\PY{l+m+mi}{256}\PY{p}{)}\PY{p}{]}\PY{p}{)}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{uint8}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{n}{img\PYZus{}gamma} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{LUT}\PY{p}{(}\PY{n}{image}\PY{p}{,} \PY{n}{table}\PY{p}{)} \PY{k}{return} \PY{n}{img\PYZus{}gamma} \end{Verbatim} \end{tcolorbox} \subsection{Gaussian smoothing $\sigma = 1.5$} Gaussian smoothing is used to reduce sharp transitions in intensities in images(blurring). The extent of blurring depends on both the kernel size and the standard deviation $\sigma$. Each pixel's value is recalculated as the weighted sum of its neighbor pixels where weights are determined by the Gaussian Normal function. Weight decreases as the distance between central pixel and a given pixel increases. Also if the $\sigma$ increases, weights given to the neighbor pixels increases and their contribution to determine the central pixel value increases which makes the image more blur. The effect of kernel size is depicted in the following figures. As kernel size increase more pixels contribute to the calculation of central pixel's value which makes the image more blur. \begin{figure}[!h] \centering \subfigure[Original Image] { \includegraphics[scale=0.45]{figures/eoriginal} } \subfigure[Kernel Size = 7] { \includegraphics[scale=0.45]{figures/SmoothkernelS7} } \subfigure[Kernel Size = 13] { \includegraphics[scale=0.45]{figures/SmoothkernelS13} } \subfigure[Kernel Size = 21] { \includegraphics[scale=0.45]{figures/SmoothkernelS21} } \caption{Gaussian smoothing $\sigma = 1.5$} \end{figure} \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{4}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{k}{def} \PY{n+nf}{gaussianSmooth}\PY{p}{(}\PY{n}{image}\PY{p}{,} \PY{n}{kernelSize}\PY{p}{,} \PY{n}{sigma}\PY{p}{)}\PY{p}{:} \PY{n}{max\PYZus{}abs} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{floor}\PY{p}{(}\PY{n}{kernelSize}\PY{o}{/}\PY{l+m+mi}{2}\PY{p}{)} \PY{c+c1}{\PYZsh{} If kernelSize = 11} \PY{n}{x\PYZus{}range} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{max\PYZus{}abs}\PY{p}{,}\PY{n}{max\PYZus{}abs} \PY{o}{+}\PY{l+m+mi}{1}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{)} \PY{c+c1}{\PYZsh{}(from \PYZhy{}5 to +5 range)} \PY{n}{y\PYZus{}range} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{arange}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{n}{max\PYZus{}abs}\PY{p}{,}\PY{n}{max\PYZus{}abs} \PY{o}{+}\PY{l+m+mi}{1}\PY{p}{,}\PY{l+m+mi}{1}\PY{p}{)} \PY{c+c1}{\PYZsh{}(from \PYZhy{}5 to +5 range)} \PY{n}{X}\PY{p}{,}\PY{n}{Y} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{meshgrid}\PY{p}{(}\PY{n}{x\PYZus{}range}\PY{p}{,} \PY{n}{y\PYZus{}range}\PY{p}{)} \PY{n}{kernel} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{exp}\PY{p}{(}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{p}{(}\PY{n}{X}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2} \PY{o}{+} \PY{n}{Y}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{/}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{*}\PY{n}{sigma}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)}\PY{p}{)}\PY{o}{/}\PY{p}{(}\PY{l+m+mi}{2}\PY{o}{*}\PY{n}{np}\PY{o}{.}\PY{n}{pi}\PY{o}{*}\PY{n}{sigma}\PY{o}{*}\PY{o}{*}\PY{l+m+mi}{2}\PY{p}{)}\PY{c+c1}{\PYZsh{} Bulding Gaussian kernel} \PY{n}{smoothed\PYZus{}img} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{filter2D}\PY{p}{(}\PY{n}{image}\PY{p}{,}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{,}\PY{n}{kernel}\PY{p}{)}\PY{c+c1}{\PYZsh{} Convolution of the image with the kernel} \PY{k}{return} \PY{n}{smoothed\PYZus{}img} \end{Verbatim} \end{tcolorbox} \subsection{Unsharp masking} Unsharp masking is an image sharpening method which is used to highlight intensity transitions in the image. It has following three main steps as depicted in the figures. \textbf{(1.)} Original image is blurred using an averaging kernel(\textit{here Gaussian kernel is used.}). \textbf{(2.)} Blurred image is subtracted form the original image to obtain the ``mask''. \textbf{(3.)} ``Mask'' is then added to the original image to obtain the sharpened image. To eliminate overflow occurs in the addition of two images OpenCV's {\tt addWeighted} function is used. \begin{figure}[!h] \centering \subfigure[Original Image] { \includegraphics[scale=0.25]{figures/foriginal} } \subfigure[Gaussian Blurred] { \includegraphics[scale=0.25]{figures/blurred} } \subfigure[Mask + 125] { \includegraphics[scale=0.25]{figures/mask} } \subfigure[Sharpened Image] { \includegraphics[scale=0.25]{figures/sharpened} } \caption{Unsharp masking} \end{figure} \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{5}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{n}{sigma} \PY{o}{=} \PY{l+m+mi}{2} \PY{n}{kernel} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{getGaussianKernel}\PY{p}{(}\PY{l+m+mi}{5}\PY{p}{,} \PY{n}{sigma}\PY{p}{)} \PY{c+c1}{\PYZsh{}create the gaussian kernel} \PY{n}{blurred} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{sepFilter2D}\PY{p}{(}\PY{n}{img}\PY{p}{,} \PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{,} \PY{n}{kernel}\PY{p}{,} \PY{n}{kernel}\PY{p}{,} \PY{n}{anchor}\PY{o}{=}\PY{p}{(}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{,}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{)}\PY{p}{,} \PY{n}{delta}\PY{o}{=}\PY{l+m+mi}{0}\PY{p}{,} \PY{n}{borderType}\PY{o}{=}\PY{n}{cv}\PY{o}{.}\PY{n}{BORDER\PYZus{}REPLICATE}\PY{p}{)} \PY{n}{mask} \PY{o}{=} \PY{n}{img}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float32}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{o}{\PYZhy{}} \PY{n}{blurred}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float32}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{n}{k} \PY{o}{=} \PY{l+m+mi}{1} \PY{c+c1}{\PYZsh{} when k =1 : unsharp masking, when k\PYZgt{}1 : Highboost Filtering} \PY{n}{sharpened} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{addWeighted}\PY{p}{(}\PY{n}{img}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{float32}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{p}{,} \PY{l+m+mf}{1.}\PY{p}{,} \PY{n}{mask}\PY{p}{,} \PY{n}{k}\PY{p}{,} \PY{l+m+mi}{0}\PY{p}{)} \end{Verbatim} \end{tcolorbox} \subsection{Median filtering } Non-linear Median filter is heavily used to remove random noises like salt and pepper noise from images due to its excellence noise-reduction capability over any other averaging filter. As its name implies it replaces value of the central pixel by the median of the intensity values in the neighborhood of that pixel. As following figures depict noise in the figure (b) is completely removed by a $5 \times 5$ median filter which is not possible with an averaging filter like Gaussian. \begin{figure}[!h] \centering \subfigure[Original Image] { \includegraphics[scale=0.23]{figures/goriginal} } \subfigure[Adding Salt \& Pepper Noise] { \includegraphics[scale=0.23]{figures/saltpepper} } \subfigure[Kernel Size = 3] { \includegraphics[scale=0.23]{figures/medianfilterimage3} } \subfigure[Kernel Size = 5] { \includegraphics[scale=0.23]{figures/medianfilterimage5} } \caption{Median filtering } \end{figure} \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{6}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{n}{saltpepper} \PY{o}{=} \PY{n}{noisy}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{s\PYZam{}p}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{img}\PY{p}{)}\PY{c+c1}{\PYZsh{} noise generated using noisy fun @:stackoverflow.com/a/30609854} \PY{n}{kernelSize} \PY{o}{=} \PY{l+m+mi}{3} \PY{n}{medianfiltered\PYZus{}image} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{medianBlur}\PY{p}{(}\PY{n}{saltpepper}\PY{p}{,} \PY{n}{kernelSize}\PY{p}{)} \end{Verbatim} \end{tcolorbox} \subsection{Bilateral filtering} Bilateral filter extends the idea of Gaussian smoothing by adding \textbf{\textit{edge preserving capability}} which is not possible in the Gaussian filtering because there, only the Spatial distance to the pixels' from the central pixel were considered when applying the weights(\textit{Same Gaussian kernel everywhere regardless of the pixel's intensity}) and therefore \textbf{\textit{Gaussian filter averages across the edges}} assuming that pixels' intensity value do not change rapidly over the window. As a consequence the same weight may be applied to a pixel on an edge(say high intensity) and a pixel near an edge(say low intensity) when calculating the central pixel's value of a window centered at a pixel near an edge.\\ In the bilateral filter \textbf{\textit{intensities of the neighborhood pixels are also considered}} when applying the weights, in addition to the spatial distance. This makes it possible to \textbf{\textit{eliminate the averaging across edges}}. As following figures shows when $\sigma_r$ approaches $\infty$, bilateral filter gives the result of the Gaussian filter. Here $\sigma_s$ is spatial deviation(\textit{spatial extent of the kernel}) while $\sigma_r$ is the color space deviation(\textit{minimum amplitude of an edge}). \begin{figure}[!h] \centering \subfigure[Original Image] { \includegraphics[scale=0.37]{figures/horiginal} } \subfigure[Gaussian Kernel Size = 9, $\sigma_s=6$] { \includegraphics[scale=0.37]{figures/gaussianB} } \subfigure[Bilateral Kernel Size = 9, $\sigma_s = 6$, $\sigma_r = 100$ ] { \includegraphics[scale=0.37]{figures/bl5} } \subfigure[Bilateral Kernel Size = 13, $\sigma_s = 6$, $\sigma_r = 10$] { \includegraphics[scale=0.37]{figures/bl9} } \caption{Bilateral filtering} \end{figure} \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{7}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{c+c1}{\PYZsh{}dst = cv.bilateralFilter(src, d(KernelSize), sigmaColor, sigmaSpace)} \PY{n}{bilateral1} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{bilateralFilter}\PY{p}{(}\PY{n}{img}\PY{p}{,}\PY{l+m+mi}{9}\PY{p}{,}\PY{l+m+mi}{100}\PY{p}{,}\PY{l+m+mi}{6}\PY{p}{)}\PY{c+c1}{\PYZsh{} Edges are blurred. Almost Gaussian} \PY{n}{bilateral2} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{bilateralFilter}\PY{p}{(}\PY{n}{img}\PY{p}{,}\PY{l+m+mi}{13}\PY{p}{,}\PY{l+m+mi}{10}\PY{p}{,}\PY{l+m+mi}{6}\PY{p}{)}\PY{c+c1}{\PYZsh{} Edges are preserved} \end{Verbatim} \end{tcolorbox} \vspace{5mm} \hrule \section{Part 2: Count the rice grains in the rice image} The objective of counting the rice grains can be achieved through binary segmentation as we have only two different object types namely rice grains and the background. Since the image has different lighting conditions, \textbf{\textit{adaptive thresholding}} must be used for binary segmentation. Optimum parameter values for the thresholding function was obtained though trial and error. To get rid of the unwanted white noise in the background and to detach connected grains as depicted in the figure (b) \textbf{\textit{erosion morphological transformation}} is used(\textit{Rectangular kernel is used over elliptic and cross shape kernels since it was found to be the best at achieving the aforementioned requirements}).\\ After the above post-processing what is left is just to count the distinct white objects(rice grains) in the figure (c). For that Connected Components Analysis(CCA) is used. It gives each distinct grain a distinct label(\textit{an integer starting form 0(for background) to some number}). This can be done through OpenCV's {\tt connectedComponents} function which returns total number of labels and the labeled image. Since this total number of labels includes the background as well, we need to subtract 1 from it to get the grain count. All the components in the labeled image can be easily visualized through a proper color map as depicted in figure (e). Before map the colors, figure (d) is normalized to get a uniform intensity distribution in the range[0, 255] which makes the color mapping more distributed.\\ {\tt Through the following algorithm it was found that there are 100 grains in the given image.} \begin{figure}[!h] \centering \subfigure[Gray Scale Image] { \includegraphics[scale=0.38]{figures/part2/2original} } \subfigure[Adaptive Thresholding] { \includegraphics[scale=0.38]{figures/part2/img_adapt_thresh} } \subfigure[Erosion] { \includegraphics[scale=0.38]{figures/part2/eroded_img} } \subfigure[Connected Components] { \includegraphics[scale=0.38]{figures/part2/labeledImg} } \subfigure[Color Mapped Image] { \includegraphics[scale=0.38]{figures/part2/imgColorMap} } \caption{Counting the rice grains} \end{figure} \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{8}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{c+c1}{\PYZsh{} reading the image as an eight bit grayscale image} \PY{n}{img} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{imread}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{../a01images/rice.png}\PY{l+s+s2}{\PYZdq{}}\PY{p}{,} \PY{n}{cv}\PY{o}{.}\PY{n}{IMREAD\PYZus{}GRAYSCALE}\PY{p}{)} \PY{c+c1}{\PYZsh{} adaptive thresholding due to non uniform illumination in the image} \PY{n}{kernelSize}\PY{p}{,} \PY{n}{C} \PY{o}{=} \PY{l+m+mi}{25}\PY{p}{,}\PY{o}{\PYZhy{}}\PY{l+m+mi}{10} \PY{n}{img\PYZus{}adapt\PYZus{}thresh} \PY{o}{=} \PY{n}{th2} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{adaptiveThreshold}\PY{p}{(}\PY{n}{img}\PY{p}{,}\PY{l+m+mi}{255}\PY{p}{,}\PY{n}{cv}\PY{o}{.}\PY{n}{ADAPTIVE\PYZus{}THRESH\PYZus{}MEAN\PYZus{}C}\PY{p}{,} \PY{n}{cv}\PY{o}{.}\PY{n}{THRESH\PYZus{}BINARY}\PY{p}{,}\PY{n}{kernelSize}\PY{p}{,} \PY{n}{C}\PY{p}{)} \PY{c+c1}{\PYZsh{} Morphological transf: Erosion to eliminate white noise and detach connected objects} \PY{n}{ksize} \PY{o}{=} \PY{l+m+mi}{3} \PY{n}{kernel} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{getStructuringElement}\PY{p}{(}\PY{n}{cv}\PY{o}{.}\PY{n}{MORPH\PYZus{}RECT}\PY{p}{,}\PY{p}{(}\PY{n}{ksize}\PY{p}{,}\PY{n}{ksize}\PY{p}{)}\PY{p}{)} \PY{n}{eroded\PYZus{}img} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{erode}\PY{p}{(}\PY{n}{img\PYZus{}adapt\PYZus{}thresh}\PY{p}{,} \PY{n}{kernel}\PY{p}{)} \PY{c+c1}{\PYZsh{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}Connected components Analysis(CCA)\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}} \PY{n}{num\PYZus{}labels}\PY{p}{,} \PY{n}{labeledImg} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{connectedComponents}\PY{p}{(}\PY{n}{eroded\PYZus{}img}\PY{p}{)} \PY{c+c1}{\PYZsh{} Background is considered as another object in CCA. Therfore it needs to be subtracted} \PY{n}{num\PYZus{}grains} \PY{o}{=} \PY{n}{num\PYZus{}labels} \PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{;} \PY{n+nb}{print}\PY{p}{(}\PY{n}{num\PYZus{}grains}\PY{p}{)} \PY{c+c1}{\PYZsh{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}Show components using a color Map.\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}\PYZhy{}} \PY{p}{(}\PY{n}{minVal}\PY{p}{,} \PY{n}{maxVal}\PY{p}{,} \PY{n}{minLoc}\PY{p}{,} \PY{n}{maxLoc}\PY{p}{)} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{minMaxLoc}\PY{p}{(}\PY{n}{labeledImg}\PY{p}{)}\PY{c+c1}{\PYZsh{} find min,max pixel values \& locations } \PY{n}{labeledImg} \PY{o}{=} \PY{p}{(}\PY{l+m+mi}{255}\PY{o}{/}\PY{p}{(}\PY{n}{maxVal}\PY{o}{\PYZhy{}}\PY{n}{minVal}\PY{p}{)}\PY{p}{)} \PY{o}{*} \PY{p}{(}\PY{n}{labeledImg} \PY{o}{\PYZhy{}} \PY{n}{minVal}\PY{p}{)}\PY{c+c1}{\PYZsh{} Normalizing image so, min= 0 \& max = 255.} \PY{n}{imgColorMap} \PY{o}{=} \PY{n}{cv}\PY{o}{.}\PY{n}{applyColorMap}\PY{p}{(}\PY{n}{labeledImg}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{uint8}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)}\PY{p}{,} \PY{n}{cv}\PY{o}{.}\PY{n}{COLORMAP\PYZus{}RAINBOW}\PY{p}{)}\PY{c+c1}{\PYZsh{} Applying color map} \PY{n}{imgColorMap}\PY{p}{[}\PY{n}{labeledImg}\PY{o}{==}\PY{l+m+mi}{0}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{0}\PY{c+c1}{\PYZsh{} Making the background black} \PY{n}{plt}\PY{o}{.}\PY{n}{imshow}\PY{p}{(}\PY{n}{imgColorMap}\PY{p}{[}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{,}\PY{p}{:}\PY{p}{:}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}\PY{c+c1}{\PYZsh{} Display colormapped labels} \end{Verbatim} \end{tcolorbox} \vspace{5mm} \hrule \section{Part 3: Zoom Images} Following code implements \textbf{\textit{Nearest Neighbor}} and \textbf{\textit{Bi-linear Interpolation}} methods of image zooming. As following figure depicts bi-linear interpolation method is better than nearest neighbor method since it interpolates each pixel's intensity value using its neighbors' values rather than simply taking the nearest neighbor's value when assigning values to the pixels in the zoomed image. Because of this reason continuous nature of intensities is violated and pixel's rectangular structure is clearly visible in the image, zoomed using the nearest neighbor method which is not the case in the bi-linear interpolation method. \begin{figure}[!h] \centering \subfigure[Nearest Neighbor Method] { \includegraphics[scale=0.85]{figures/part3/zoomedImgnncrop} } \subfigure[Bilinear Interpolation Method] { \includegraphics[scale=0.825]{figures/part3/zoomedImgbicrop} } \caption{Zooming Images} \end{figure} These two methods can be easily explained using a count example as follows. Consider a pixel in a zoomed image($1920 \times1200$) whose coordinates are ($235,526$). Assume this image was obtained by scaling an image($480\times300$) by a factor of 4. \begin{itemize} \item First step is common to the both methods, that is calculating the corresponding pixel in the original source image by dividing the coordinates by the scaling factor. Therefore source coordinates = ($235/4,526/4$) = ($58.75, 131.5$) \item In the {\tt Nearest Neighbor Method} these coordinates are rounded to the nearest integers within the source image dimensions. Then corresponding pixel in the source image = ($59, 132$) and intensity of that pixel is assigned to the pixel($235,526$) in the zoomed image. \item But in the {\tt Bi-linear Interpolation Method} it considers intensities of all of its neighbors. That is intensities of, ($58, 131$),($58, 132$),($59, 131$) and ($59, 132$) are considered and it interpolates the intensity of an imaginary pixel at the coordinates($58.75, 131.5$) using those intensities. That intensity value is then assigned to the corresponding pixel($235,526$) in the zoomed image. \end{itemize} Because of this difference in intensity assigning procedure, Bi-linear Interpolation Method is computationally expensive and its quality is much better than the Nearest Neighbor Method. \vfill \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder] \prompt{In}{incolor}{9}{\boxspacing} \begin{Verbatim}[commandchars=\\\{\}] \PY{k}{def} \PY{n+nf}{zoom}\PY{p}{(}\PY{n}{image}\PY{p}{,} \PY{n}{scaling\PYZus{}factor}\PY{p}{,} \PY{n}{method}\PY{p}{)}\PY{p}{:} \PY{n}{img} \PY{o}{=} \PY{n}{image} \PY{n}{sf} \PY{o}{=} \PY{n}{scaling\PYZus{}factor} \PY{c+c1}{\PYZsh{} Determining dimensions of the zoomed image} \PY{k}{if} \PY{n+nb}{len}\PY{p}{(}\PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{)} \PY{o}{==} \PY{l+m+mi}{2}\PY{p}{:} \PY{c+c1}{\PYZsh{} for GRAYSCALE images} \PY{n}{zoomedImgDims} \PY{o}{=} \PY{p}{[}\PY{n+nb}{int}\PY{p}{(}\PY{n}{dim}\PY{o}{*}\PY{n}{sf}\PY{p}{)} \PY{k}{for} \PY{n}{dim} \PY{o+ow}{in} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{]} \PY{k}{else}\PY{p}{:} \PY{c+c1}{\PYZsh{} for COLOR images} \PY{n}{zoomedImgDims} \PY{o}{=} \PY{p}{[}\PY{n+nb}{int}\PY{p}{(}\PY{n}{dim}\PY{o}{*}\PY{n}{sf}\PY{p}{)} \PY{k}{for} \PY{n}{dim} \PY{o+ow}{in} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{]} \PY{n}{zoomedImgDims}\PY{p}{[}\PY{l+m+mi}{2}\PY{p}{]} \PY{o}{=} \PY{l+m+mi}{3} \PY{n}{zoomedImg} \PY{o}{=} \PY{n}{np}\PY{o}{.}\PY{n}{zeros}\PY{p}{(}\PY{n}{zoomedImgDims}\PY{p}{,} \PY{n}{dtype} \PY{o}{=} \PY{n}{img}\PY{o}{.}\PY{n}{dtype}\PY{p}{)}\PY{c+c1}{\PYZsh{} declaring an empty array to store values} \PY{c+c1}{\PYZsh{}====================Nearest Neighbour Mehtod(NNM)=========================} \PY{k}{if} \PY{n}{method} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{nn}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{k}{for} \PY{n}{row} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{zoomedImg}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}\PY{p}{:} \PY{n}{source\PYZus{}row} \PY{o}{=} \PY{n+nb}{round}\PY{p}{(}\PY{n}{row}\PY{o}{/}\PY{n}{sf}\PY{p}{)}\PY{c+c1}{\PYZsh{} Calculating corresponding pixels in original image } \PY{k}{if} \PY{n}{source\PYZus{}row} \PY{o}{\PYZgt{}} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{:} \PY{n}{source\PYZus{}row} \PY{o}{=} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{c+c1}{\PYZsh{} Overflow handling} \PY{k}{for} \PY{n}{column} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{zoomedImg}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}\PY{p}{:} \PY{n}{source\PYZus{}column} \PY{o}{=} \PY{n+nb}{round}\PY{p}{(}\PY{n}{column}\PY{o}{/}\PY{n}{sf}\PY{p}{)}\PY{c+c1}{\PYZsh{} Calculating corresponding pixels in original image} \PY{k}{if} \PY{n}{source\PYZus{}column} \PY{o}{\PYZgt{}} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{:} \PY{n}{source\PYZus{}column} \PY{o}{=} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{c+c1}{\PYZsh{} Overflow handling} \PY{c+c1}{\PYZsh{} Assigning pixel values} \PY{k}{if} \PY{n+nb}{len}\PY{p}{(}\PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{)} \PY{o}{==} \PY{l+m+mi}{2}\PY{p}{:} \PY{n}{zoomedImg}\PY{p}{[}\PY{n}{row}\PY{p}{]}\PY{p}{[}\PY{n}{column}\PY{p}{]} \PY{o}{=} \PY{n}{img}\PY{p}{[}\PY{n}{source\PYZus{}row}\PY{p}{]}\PY{p}{[}\PY{n}{source\PYZus{}column}\PY{p}{]} \PY{k}{else}\PY{p}{:} \PY{k}{for} \PY{n}{channel} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{l+m+mi}{3}\PY{p}{)}\PY{p}{:} \PY{n}{zoomedImg}\PY{p}{[}\PY{n}{row}\PY{p}{]}\PY{p}{[}\PY{n}{column}\PY{p}{]}\PY{p}{[}\PY{n}{channel}\PY{p}{]} \PY{o}{=} \PYZbs{} \PY{n}{img}\PY{p}{[}\PY{n}{source\PYZus{}row}\PY{p}{]}\PY{p}{[}\PY{n}{source\PYZus{}column}\PY{p}{]}\PY{p}{[}\PY{n}{channel}\PY{p}{]} \PY{c+c1}{\PYZsh{}======================Bilinear Interpolation Mehtod(BIM)================== } \PY{k}{if} \PY{n}{method} \PY{o}{==} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{bi}\PY{l+s+s1}{\PYZsq{}}\PY{p}{:} \PY{k}{for} \PY{n}{row} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{zoomedImg}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{p}{)}\PY{p}{:} \PY{n}{row\PYZus{}position} \PY{o}{=} \PY{n}{row}\PY{o}{/}\PY{n}{sf}\PY{c+c1}{\PYZsh{} Calculating corresponding row in original image} \PY{n}{row\PYZus{}below} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{floor}\PY{p}{(}\PY{n}{row\PYZus{}position}\PY{p}{)}\PY{p}{)} \PY{n}{row\PYZus{}up} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{ceil}\PY{p}{(}\PY{n}{row\PYZus{}position}\PY{p}{)}\PY{p}{)} \PY{k}{if} \PY{n}{row\PYZus{}up} \PY{o}{\PYZgt{}} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{:} \PY{n}{row\PYZus{}up} \PY{o}{=} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{0}\PY{p}{]}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{c+c1}{\PYZsh{} Overflow handling} \PY{k}{for} \PY{n}{column} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{n}{zoomedImg}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{p}{)}\PY{p}{:} \PY{n}{column\PYZus{}position} \PY{o}{=} \PY{n}{column}\PY{o}{/}\PY{n}{sf}\PY{c+c1}{\PYZsh{} Calculating corresponding column in original image} \PY{n}{column\PYZus{}previous} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{floor}\PY{p}{(}\PY{n}{column\PYZus{}position}\PY{p}{)}\PY{p}{)} \PY{n}{column\PYZus{}next} \PY{o}{=} \PY{n+nb}{int}\PY{p}{(}\PY{n}{np}\PY{o}{.}\PY{n}{ceil}\PY{p}{(}\PY{n}{column\PYZus{}position}\PY{p}{)}\PY{p}{)} \PY{k}{if} \PY{n}{column\PYZus{}next} \PY{o}{\PYZgt{}} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1}\PY{p}{:} \PY{n}{column\PYZus{}next} \PY{o}{=} \PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{]}\PY{o}{\PYZhy{}}\PY{l+m+mi}{1} \PY{n}{diff1} \PY{o}{=} \PY{n}{row\PYZus{}position} \PY{o}{\PYZhy{}} \PY{n}{row\PYZus{}below} \PY{n}{diff2} \PY{o}{=} \PY{n}{column\PYZus{}position} \PY{o}{\PYZhy{}} \PY{n}{column\PYZus{}previous} \PY{k}{if} \PY{n+nb}{len}\PY{p}{(}\PY{n}{img}\PY{o}{.}\PY{n}{shape}\PY{p}{)} \PY{o}{==} \PY{l+m+mi}{2}\PY{p}{:} \PY{c+c1}{\PYZsh{} for GRAYSCALE images} \PY{n}{interVal1} \PY{o}{=} \PY{n}{img}\PY{p}{[}\PY{n}{row\PYZus{}below}\PY{p}{]}\PY{p}{[}\PY{n}{column\PYZus{}previous}\PY{p}{]}\PY{o}{*}\PY{p}{(}\PY{l+m+mi}{1}\PY{o}{\PYZhy{}}\PY{n}{diff1}\PY{p}{)}\PYZbs{} \PY{o}{+} \PY{n}{img}\PY{p}{[}\PY{n}{row\PYZus{}up}\PY{p}{]}\PY{p}{[}\PY{n}{column\PYZus{}previous}\PY{p}{]}\PY{o}{*}\PY{p}{(}\PY{n}{diff1}\PY{p}{)} \PY{n}{interVal2} \PY{o}{=} \PY{n}{img}\PY{p}{[}\PY{n}{row\PYZus{}below}\PY{p}{]}\PY{p}{[}\PY{n}{column\PYZus{}next}\PY{p}{]}\PY{o}{*}\PY{p}{(}\PY{l+m+mi}{1}\PY{o}{\PYZhy{}}\PY{n}{diff1}\PY{p}{)}\PYZbs{} \PY{o}{+} \PY{n}{img}\PY{p}{[}\PY{n}{row\PYZus{}up}\PY{p}{]}\PY{p}{[}\PY{n}{column\PYZus{}next}\PY{p}{]}\PY{o}{*}\PY{p}{(}\PY{n}{diff1}\PY{p}{)} \PY{n}{zoomedImg}\PY{p}{[}\PY{n}{row}\PY{p}{]}\PY{p}{[}\PY{n}{column}\PY{p}{]} \PY{o}{=} \PY{p}{(}\PY{n}{interVal1}\PY{o}{*}\PY{p}{(}\PY{l+m+mi}{1}\PY{o}{\PYZhy{}}\PY{n}{diff2}\PY{p}{)}\PYZbs{} \PY{o}{+} \PY{n}{interVal2}\PY{o}{*}\PY{p}{(}\PY{n}{diff2}\PY{p}{)}\PY{p}{)}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{uint8}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{k}{else}\PY{p}{:} \PY{c+c1}{\PYZsh{} for COLOR images} \PY{k}{for} \PY{n}{channel} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{l+m+mi}{3}\PY{p}{)}\PY{p}{:} \PY{n}{interVal1} \PY{o}{=} \PY{n}{img}\PY{p}{[}\PY{n}{row\PYZus{}below}\PY{p}{]}\PY{p}{[}\PY{n}{column\PYZus{}previous}\PY{p}{]}\PY{p}{[}\PY{n}{channel}\PY{p}{]}\PY{o}{*}\PY{p}{(}\PY{l+m+mi}{1}\PY{o}{\PYZhy{}}\PY{n}{diff1}\PY{p}{)}\PYZbs{} \PY{o}{+} \PY{n}{img}\PY{p}{[}\PY{n}{row\PYZus{}up}\PY{p}{]}\PY{p}{[}\PY{n}{column\PYZus{}previous}\PY{p}{]}\PY{p}{[}\PY{n}{channel}\PY{p}{]}\PY{o}{*}\PY{p}{(}\PY{n}{diff1}\PY{p}{)} \PY{n}{interVal2} \PY{o}{=} \PY{n}{img}\PY{p}{[}\PY{n}{row\PYZus{}below}\PY{p}{]}\PY{p}{[}\PY{n}{column\PYZus{}next}\PY{p}{]}\PY{p}{[}\PY{n}{channel}\PY{p}{]}\PY{o}{*}\PY{p}{(}\PY{l+m+mi}{1}\PY{o}{\PYZhy{}}\PY{n}{diff1}\PY{p}{)}\PYZbs{} \PY{o}{+} \PY{n}{img}\PY{p}{[}\PY{n}{row\PYZus{}up}\PY{p}{]}\PY{p}{[}\PY{n}{column\PYZus{}next}\PY{p}{]}\PY{p}{[}\PY{n}{channel}\PY{p}{]}\PY{o}{*}\PY{p}{(}\PY{n}{diff1}\PY{p}{)} \PY{n}{zoomedImg}\PY{p}{[}\PY{n}{row}\PY{p}{]}\PY{p}{[}\PY{n}{column}\PY{p}{]}\PY{p}{[}\PY{n}{channel}\PY{p}{]} \PY{o}{=} \PY{p}{(}\PY{n}{interVal1}\PY{o}{*}\PY{p}{(}\PY{l+m+mi}{1}\PY{o}{\PYZhy{}}\PY{n}{diff2}\PY{p}{)}\PYZbs{} \PY{o}{+} \PY{n}{interVal2}\PY{o}{*}\PY{p}{(}\PY{n}{diff2}\PY{p}{)}\PY{p}{)}\PY{o}{.}\PY{n}{astype}\PY{p}{(}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{uint8}\PY{l+s+s1}{\PYZsq{}}\PY{p}{)} \PY{k}{return} \PY{n}{zoomedImg} \end{Verbatim} \end{tcolorbox} \end{document}
```python import numpy as np import scipy.misc from scipy.fftpack import dct, idct import sys from PIL import Image import matplotlib import matplotlib.pyplot as plt import random from tqdm._tqdm_notebook import tqdm_notebook from scipy.fftpack import dct, idct import seaborn as sns from skimage.metrics import structural_similarity as ssim import pandas as pd import sympy %matplotlib inline class ImageLoader: def __init__(self, FILE_PATH): self.img = np.array(Image.open(FILE_PATH)) # 行数 self.row_blocks_count = self.img.shape[0] // 8 # 列数 self.col_blocks_count = self.img.shape[1] // 8 def get_points(self, POINT): Row = random.randint(0, len(self.img) - POINT - 1) Col = random.randint(0, len(self.img) - 1) return self.img[Row : Row + POINT, Col] def get_block(self, col, row): return self.img[col * 8 : (col + 1) * 8, row * 8 : (row + 1) * 8] # plt.rcParams['font.family'] ='sans-serif'#使用するフォント # plt.rcParams["font.sans-serif"] = "Source Han Sans" plt.rcParams["font.family"] = "Source Han Sans JP" # 使用するフォント plt.rcParams["xtick.direction"] = "in" # x軸の目盛線が内向き('in')か外向き('out')か双方向か('inout') plt.rcParams["ytick.direction"] = "in" # y軸の目盛線が内向き('in')か外向き('out')か双方向か('inout') plt.rcParams["xtick.major.width"] = 1.0 # x軸主目盛り線の線幅 plt.rcParams["ytick.major.width"] = 1.0 # y軸主目盛り線の線幅 plt.rcParams["font.size"] = 12 # フォントの大きさ plt.rcParams["axes.linewidth"] = 1.0 # 軸の線幅edge linewidth。囲みの太さ matplotlib.font_manager._rebuild() MONO_DIR_PATH = "../../Mono/" AIRPLANE = ImageLoader(MONO_DIR_PATH + "airplane512.bmp") BARBARA = ImageLoader(MONO_DIR_PATH + "barbara512.bmp") BOAT = ImageLoader(MONO_DIR_PATH + "boat512.bmp") GOLDHILL = ImageLoader(MONO_DIR_PATH + "goldhill512.bmp") LENNA = ImageLoader(MONO_DIR_PATH + "lenna512.bmp") MANDRILL = ImageLoader(MONO_DIR_PATH + "mandrill512.bmp") MILKDROP = ImageLoader(MONO_DIR_PATH + "milkdrop512.bmp") SAILBOAT = ImageLoader(MONO_DIR_PATH + "sailboat512.bmp") IMAGES = [ AIRPLANE, BARBARA, BOAT, GOLDHILL, LENNA, MANDRILL, MILKDROP, SAILBOAT ] ``` ```python # n_bar = 4 N = 8 ``` ```python IMG = LENNA ``` ```python Fk = np.zeros(IMG.img.shape) ``` ```python sampling_x = (0.5 + np.arange(N)) / N u_1 = (1 - sampling_x) ** 2 / 2 u_2 = 1 / 24 - sampling_x ** 2 / 6 + sampling_x ** 3 / 6 - sampling_x ** 4 / 24 u_3 = sampling_x ** 2 / 2 u_4 = -sampling_x ** 2 / 12 + sampling_x ** 4 / 24 ``` ```python ak = - scipy.fftpack.dct(u_1,norm="ortho") bk = scipy.fftpack.dct(u_2,norm="ortho") ck = scipy.fftpack.dct(u_3,norm="ortho") dk = scipy.fftpack.dct(u_4,norm="ortho") alpha = ak beta = ck Ak = (2 * ak - 16 * bk) / np.sqrt(N) Bk = (2 * ck - 16 * dk) / np.sqrt(N) Ck = (2 * ak - 32 * bk) / np.sqrt(N) Dk = (2 * ck - 32 * dk) / np.sqrt(N) ``` ```python def TPHLCT(IMG,N): Fk = np.zeros(IMG.img.shape) # DCT for row in range(IMG.img.shape[0] // N): for col in range(IMG.img.shape[1]): eight_points = IMG.img[N * row : N * (row + 1), col] c = scipy.fftpack.dct(eight_points,norm="ortho") Fk[N * row : N * (row + 1), col] = c # 3階 for row in range(Fk.shape[0] // N): for col in range(Fk.shape[1]): F = Fk[N * row : N * (row + 1), col] F_0_r = 0 F_1_r = 0 if row is not Fk.shape[0] // N - 1: F_0_r = Fk[N * (row + 1), col] F_1_r = Fk[N * (row + 1) + 1, col] F_0_l = 0 F_1_l = 1 if row is not 0: F_0_l = Fk[N * (row - 1), col] F_1_l = Fk[N * (row - 1) + 1, col] # 残差 F_0 = F[0] F_1 = F[1] F = ( F - Ak * (F_0 - F_0_l) - Bk * (F_0_r - F_0) - Ck * (F_1 + F_1_l) - Dk * (F_1_r + F_1) ) # F_0, F_1は残す F[0] = F_0 F[1] = F_1 # F_0 V_1 V_2 V_3 V_4 V_5 V_6 V_7 Fk[N * row : N * (row + 1), col] = F # 1階 for row in range(Fk.shape[0] // N): for col in range(Fk.shape[1]): F = Fk[N * row : N * (row + 1), col] F_0_r = 0 if row is not Fk.shape[0] // N - 1: F_0_r = Fk[N * (row + 1), col] F_0_l = 0 if row is not 0: F_0_l = Fk[N * (row - 1), col] # 残差 F_0 = F[0] F_temp = F - alpha * (F_0_r - F_0) / np.sqrt(N) - beta * (F_0 - F_0_l) / np.sqrt(N) # F_0は残す F[1] = F_temp[1] # F_0 V_1 V_2 V_3 V_4 V_5 V_6 V_7 Fk[N * row : N * (row + 1), col] = F # DCT for row in range(Fk.shape[0]): for col in range(Fk.shape[1] // N): eight_points = Fk[row, N * col : N * (col + 1)] c = scipy.fftpack.dct(eight_points,norm="ortho") Fk[row, N * col : N * (col + 1)] = c # 3階 for row in range(Fk.shape[0]): for col in range(Fk.shape[1] // N): F = Fk[row, N * col : N * (col + 1)] F_0_r = 0 F_1_r = 0 if col is not Fk.shape[1] // N - 1: F_0_r = Fk[row, N * (col + 1)] F_1_r = Fk[row, N * (col + 1) + 1] F_0_l = 0 F_1_l = 0 if col is not 0: F_0_l = Fk[row, N * (col - 1)] F_1_l = Fk[row, N * (col - 1) + 1] # 残差 F_0 = F[0] F_1 = F[1] F = ( F - Ak * (F_0 - F_0_l) - Bk * (F_0_r - F_0) - Ck * (F_1 + F_1_l) - Dk * (F_1_r + F_1) ) # F_0は残す F[0] = F_0 F[1] = F_1 # F_0 V_1 V_2 V_3 V_4 V_5 V_6 V_7 Fk[row, N * col : N * (col + 1)] = F for row in range(Fk.shape[0]): for col in range(Fk.shape[1] // N): F = Fk[row, N * col : N * (col + 1)] F_0_r = 0 if col is not Fk.shape[1] // N - 1: F_0_r = Fk[row, N * (col + 1)] F_0_l = 0 if col is not 0: F_0_l = Fk[row, N * (col - 1)] # 残差 F_0 = F[0] F_temp = F - alpha * (F_0_r - F_0) / np.sqrt(N) - beta * (F_0 - F_0_l) / np.sqrt(N) # F_0は残す F[1] = F_temp[1] # F_0 V_1 V_2 V_3 V_4 V_5 V_6 V_7 Fk[row, N * col : N * (col + 1)] = F return Fk ``` ```python # DCT係数の平均を求める ``` ```python Fk_values = np.zeros((512,512)) ``` ```python for IMG in tqdm_notebook(IMAGES): values = np.zeros((25,4)) Fk = np.zeros(IMG.img.shape) for row in range(IMG.img.shape[0] // N): for col in range(IMG.img.shape[1] // N): block = IMG.img[row * N : (row + 1) * N, col * N : (col + 1) * N] c = scipy.fftpack.dct( scipy.fftpack.dct(block, axis=0, norm="ortho"), axis=1, norm="ortho" ) Fk[row * N : (row + 1) * N, col * N : (col + 1) * N] = c Fk_values += np.abs(Fk) ``` HBox(children=(IntProgress(value=0, max=8), HTML(value=''))) ```python Fk_values /= len(IMAGES) pd.DataFrame(Fk_values).to_csv("DCT_coef_ave.csv",header=False,index=False) ``` ```python # 各n_barの残差係数の平均を求める ``` ```python Vk_values = np.zeros((512,512)) ``` ```python Vk_values = np.zeros((512,512)) for IMG in tqdm_notebook(IMAGES): Fk = TPHLCT(IMG,N) Vk_values += np.abs(Fk) pd.DataFrame(Vk_values / len(IMAGES)).to_csv("TPHLCT_coef_ave.csv",header=False,index=False) ``` HBox(children=(IntProgress(value=0, max=8), HTML(value=''))) ```python # DCT係数を読み込む ``` ```python Fk_values = pd.read_csv("DCT_coef_ave.csv",header=None).values ``` ```python # 残差係数を読み込む ``` ```python Vk_values = pd.read_csv("TPHLCT_coef_ave.csv",header=None).values ``` ```python # NxNブロック1個当たりの係数の平均を求める ``` ```python Fk_block_ave_values = np.zeros((N,N)) for row in range(IMG.img.shape[0] // N): for col in range(IMG.img.shape[1] // N): if col == 0: continue if col == IMG.img.shape[1] // N -1: continue if row == 0: continue if row == IMG.img.shape[0] // N -1: continue block = Fk_values[row * N : (row + 1) * N, col * N : (col + 1) * N] Fk_block_ave_values += np.abs(block) Fk_block_ave_values /= (IMG.img.shape[0]//N)**2 ``` ```python Vk_block_ave_values = np.zeros((N,N)) for row in range(IMG.img.shape[0] // N): for col in range(IMG.img.shape[1] // N): if col == 0: continue if col == IMG.img.shape[1] // N -1: continue if row == 0: continue if row == IMG.img.shape[0] // N -1: continue block = Vk_values[row * N : (row + 1) * N, col * N : (col + 1) * N] Vk_block_ave_values += np.abs(block) Vk_block_ave_values /= (IMG.img.shape[0]//N)**2 ``` ```python df = pd.DataFrame(columns=["G(k_1,k_2)"]) ``` ```python for index in range(1,k_max,1): for i in range(index): Gk1k2_1 = [] Gk1k2_2 = [] Vk = Vk_block_ave_values[i,index] Fk = Fk_block_ave_values[i,index] Gk1k2_1.append(100 * (1 - Vk/Fk)) Vk = Vk_block_ave_values[index,i] Fk = Fk_block_ave_values[index,i] Gk1k2_2.append(100 * (1 - Vk/Fk)) df.loc["(" + str(i) + "," + str(index) + ")"] = Gk1k2_1 df.loc["(" + str(index) + "," + str(i) + ")"] = Gk1k2_2 Gk1k2 = [] Vk = Vk_block_ave_values[index,index] Fk = Fk_block_ave_values[index,index] Gk1k2.append(100 * (1 - Vk/Fk)) df.loc["(" + str(index) + "," + str(index) + ")"] = Gk1k2 Gk1k2 = [] Vk_sum = 0 Fk_sum = 0 for row in range(N): for col in range(N): if row > k_max-1 or col > k_max-1: Vk_sum += Vk_block_ave_values[row,col] Fk_sum += Fk_block_ave_values[row,col] Gk1k2.append(100 * (1 - Vk_sum/Fk_sum)) df.loc["others"] = Gk1k2 ``` ```python df.to_csv("TPHLCT_high_freq_comp.csv") df ``` <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>G(k_1,k_2)</th> </tr> </thead> <tbody> <tr> <th>(0,1)</th> <td>20.717614</td> </tr> <tr> <th>(1,0)</th> <td>22.109009</td> </tr> <tr> <th>(1,1)</th> <td>13.555398</td> </tr> <tr> <th>(0,2)</th> <td>18.142591</td> </tr> <tr> <th>(2,0)</th> <td>17.046191</td> </tr> <tr> <th>(1,2)</th> <td>12.608437</td> </tr> <tr> <th>(2,1)</th> <td>12.401644</td> </tr> <tr> <th>(2,2)</th> <td>11.519603</td> </tr> <tr> <th>(0,3)</th> <td>8.359163</td> </tr> <tr> <th>(3,0)</th> <td>8.110313</td> </tr> <tr> <th>(1,3)</th> <td>4.960569</td> </tr> <tr> <th>(3,1)</th> <td>6.425333</td> </tr> <tr> <th>(2,3)</th> <td>6.951200</td> </tr> <tr> <th>(3,2)</th> <td>6.964452</td> </tr> <tr> <th>(3,3)</th> <td>5.062636</td> </tr> <tr> <th>(0,4)</th> <td>5.381535</td> </tr> <tr> <th>(4,0)</th> <td>5.198777</td> </tr> <tr> <th>(1,4)</th> <td>2.939087</td> </tr> <tr> <th>(4,1)</th> <td>3.619396</td> </tr> <tr> <th>(2,4)</th> <td>3.901762</td> </tr> <tr> <th>(4,2)</th> <td>4.711877</td> </tr> <tr> <th>(3,4)</th> <td>4.129811</td> </tr> <tr> <th>(4,3)</th> <td>4.055053</td> </tr> <tr> <th>(4,4)</th> <td>2.734539</td> </tr> <tr> <th>others</th> <td>1.490762</td> </tr> </tbody> </table> </div> ```python ```
import Tcl module TclDemos using Tcl # Define some shortcuts. const resume = Tcl.resume const cget = Tcl.cget const grid = Tcl.grid const pack = Tcl.pack const place = Tcl.place const list = Tcl.list #const tkgetpixels = Tcl.getpixels const getparent = Tcl.getparent const getpath = Tcl.getpath const getinterp = Tcl.getinterp const createcommand = Tcl.createcommand function addseedismiss(parent, child) #import Tcl: list ## See Code / Dismiss buttons interp = getinterp(parent) w = TtkFrame(parent, child) if isdefined(:TtkSeparator) sep = TtkSeparator(w, "sep") else sep = TtkFrame(w, "sep", height=2, relief="sunken") end grid(sep, columnspan=4, row=0, sticky="ew", pady="2") dismiss = TtkButton(w,"dismiss", text="Dismiss", #image="::img::delete", compound="left", command=list("destroy", interp("winfo","toplevel",w))) # createcommand(interp, "jlcallback", (args...) -> println("Ouch!")) code = TtkButton(w, "code", text="See Code", #image="::img::view", compound = "left", command = (args...) -> println("Ouch!")) buttons = (dismiss, code) #set buttons [list x $w.code $w.dismiss] #if {[llength $vars]} { # TtkButton $w.vars -text [mc "See Variables"] \ # -image ::img::view -compound left \ # -command [concat [list showVars $w.dialog] $vars] # set buttons [linsert $buttons 1 $w.vars] #} #if {$extra ne ""} { # set buttons [linsert $buttons 1 [uplevel 1 $extra]] #} #grid {*}$buttons -padx 4 -pady 4 #grid columnconfigure $w 0 -weight 1 grid(buttons..., padx=4, pady=4) grid("columnconfigure", w, 0, weight=1) #if {[tk windowingsystem] eq "aqua"} { # foreach b [lrange $buttons 1 end] {$b configure -takefocus 0} # grid configure sep -pady 0 # grid configure {*}$buttons -pady {10 12} # grid configure [lindex $buttons 1] -padx {16 4} # grid configure [lindex $buttons end] -padx {4 18} #} return w end function labelframedemo() interp = tkstart() wname = ".labelframe" interp("catch {destroy $wname}") w = TkToplevel(wname) interp("wm","title",w,"Labelframe Demonstration") interp("wm","iconname",w,"labelframe") # Some information msg = TkLabel(w, "msg", #font="Helveltica", wraplength="4i", justify="left", text="Labelframes are used to group related widgets together. The label may be either plain text or another widget.") pack(msg, side="top") ## See Code / Dismiss buttons btns = addseedismiss(w, "buttons") pack(btns, side="bottom", fill="x") # Demo area wf = TkFrame(w, "f") pack(wf, side="bottom", fill="both", expand=true) # A group of radiobuttons in a labelframe f = TkLabelframe(wf, "f", text="Value", padx=2, pady=2) grid(f, row=0, column=0, pady="2m", padx="2m") for value in 1:4 pack(TkRadiobutton(f,"b$value", text="This is value $value", variable="lfdummy", value=value), side="top", fill="x", pady=2) end # Using a label window to control a group of options. interp(raw""" proc lfEnableButtons {w} { foreach child [winfo children $w] { if {$child == "$w.cb"} continue if {$::lfdummy2} { $child configure -state normal } else { $child configure -state disabled } } } """) f2 = TkLabelframe(wf,"f2", pady=2, padx=2) f2_cb = TkCheckbutton(f2,"cb", text="Use this option.", variable="lfdummy2", command="lfEnableButtons $f2", padx=0) f2("configure",labelwidget=f2_cb) grid(f2, row=0, column=1, pady="2m", padx="2m") for t in 0:2 pack(TkCheckbutton(f2,"b$t", text="Option$(t+1)"), side="top", fill="x", pady=2) end interp("lfEnableButtons", f2) grid("columnconfigure", wf, (0,1), weight=1) end function runtests2() if false interp = getinterp() interp("package require Tk"); resume() name = interp("image create photo -file /home/eric/work/code/CImg/CImg-1.5.5/examples/img/lena.pgm") interp("pack [button .b -image $name]") d = Tcl.getpixels(interp, name, Val{:red}); else Tcl.eval("package require Tk"); resume() name = Tcl.eval("image create photo -file /home/eric/work/code/CImg/CImg-1.5.5/examples/img/lena.pgm") Tcl.eval("pack [button .b -image $name]") d = Tcl.getpixels(name, Val{:red}); end return d; end end
Local Scientific Coordinator (LSC) is wanted for ISABEL 2011. The LSC will be responsible for the definition and the coordination of the Technical Programme (i.e., conference theme, tracks and topics; call for papers; committees, invited organizers and speakers; dissemination sources; review process; programme structure, etc.). The LSC position was created to remove the burden of the overall practical organization and the risk therein involved from the so-called (Local) Organizing Committee. ISABEL has embraced a new vest by restructuring and renewing its internal organization, and by proposing its own model for organizing international conferences. The Local Scientific Coordinator will elect its committee and will be titled General Chair of ISABEL 2011. The Local Scientific Coordinator's Institution will receive a percentage from the eventual profit, which will be negotiated on the base of the number of regular submissions received, the number of organizers (e.g., special sessions organizers) and speakers invited, and the number of patrons and sponsors successfully involved. Note that ISABEL will provide project management support based on a consensual work/time plan and an internal initial training concerning ISABEL policies, guidelines and templates. Read more and find all the required documentation for your candidature here. Interested candidates are required to send all their material (i.e., forms, attachments and any additional information) electronically to [email protected] by September 15, 2010. The Board of Directors along with the International Scientific Committee will then gather and vision the information sent by all candidates and, on the base of strategic as well as scientific considerations, will decide who to elect Local Scientific Coordinator of ISABEL 2011. The notifications will take place by September 30, 2010. ISABEL has enormously evolved in 2010 and has emerged as one of the fastest-growing and leading emerging interdisciplinary conferences worldwide.
Formal statement is: lemma hol_pal_lem2: assumes S: "convex S" "open S" and abc: "a \<in> S" "b \<in> S" "c \<in> S" and "d \<noteq> 0" and lek: "d \<bullet> a \<le> k" "d \<bullet> b \<le> k" and holf1: "f holomorphic_on {z. z \<in> S \<and> d \<bullet> z < k}" and holf2: "f holomorphic_on {z. z \<in> S \<and> k < d \<bullet> z}" and contf: "continuous_on S f" shows "contour_integral (linepath a b) f + contour_integral (linepath b c) f + contour_integral (linepath c a) f = 0" Informal statement is: If $f$ is holomorphic on the interior of a convex open set $S$ and continuous on $S$, then the integral of $f$ around any triangle in $S$ is zero.
module Data.DynamicTree where import Lvl open import Data.List open import Data.Option open import Functional as Fn open import Type private variable ℓ ℓᵢ : Lvl.Level private variable T A B : Type{ℓ} data Node (T : Type{ℓ}) : Type{ℓ} where node : T → List(Node(T)) → Node(T) DynamicTree : Type{ℓ} → Type{ℓ} DynamicTree(T) = Option(Node(T))
State Before: α : Type u_1 β : Type ?u.5613 G₀ : Type u_2 inst✝³ : DivInvMonoid G₀ inst✝² : TopologicalSpace G₀ inst✝¹ : ContinuousMul G₀ f : α → G₀ s : Set α l : Filter α inst✝ : TopologicalSpace α hf : Continuous f y : G₀ ⊢ Continuous fun x => f x / y State After: no goals Tactic: simpa only [div_eq_mul_inv] using hf.mul continuous_const
Formal statement is: lemma lborel_distr_plus: fixes c :: "'a::euclidean_space" shows "distr lborel borel ((+) c) = lborel" Informal statement is: The distribution of the random variable $X + c$ is the same as the distribution of $X$.
Formal statement is: lemma pole_theorem: assumes holg: "g holomorphic_on S" and a: "a \<in> interior S" and eq: "\<And>z. z \<in> S - {a} \<Longrightarrow> g z = (z - a) * f z" shows "(\<lambda>z. if z = a then deriv g a else f z - g a/(z - a)) holomorphic_on S" Informal statement is: Suppose $g$ is holomorphic on a set $S$ and $a$ is an interior point of $S$. Suppose that for all $z \in S - \{a\}$, we have $g(z) = (z - a)f(z)$. Then the function $f(z) - \frac{g(a)}{z - a}$ is holomorphic on $S$.
(* Title: HOL/Auth/n_mutualExFsm_lemma_on_inv__4.thy Author: Yongjian Li and Kaiqiang Duan, State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences Copyright 2016 State Key Lab of Computer Science, Institute of Software, Chinese Academy of Sciences *) header{*The n_mutualExFsm Protocol Case Study*} theory n_mutualExFsm_lemma_on_inv__4 imports n_mutualExFsm_base begin section{*All lemmas on causal relation between inv__4 and some rule r*} lemma n_fsmVsinv__4: assumes a1: "(\<exists> i. i\<le>N\<and>r=n_fsm i)" and a2: "(\<exists> p__Inv0. p__Inv0\<le>N\<and>f=inv__4 p__Inv0)" shows "invHoldForRule s f r (invariants N)" (is "?P1 s \<or> ?P2 s \<or> ?P3 s") proof - from a1 obtain i where a1:"i\<le>N\<and>r=n_fsm i" apply fastforce done from a2 obtain p__Inv0 where a2:"p__Inv0\<le>N\<and>f=inv__4 p__Inv0" apply fastforce done have "(i=p__Inv0)\<or>(i~=p__Inv0)" apply (cut_tac a1 a2, auto) done moreover { assume b1: "(i=p__Inv0)" have "((formEval (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)) s))\<or>((formEval (andForm (andForm (eqn (IVar (Ident ''x'')) (Const true)) (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const T))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)))) s))\<or>((formEval (andForm (andForm (neg (eqn (IVar (Ident ''x'')) (Const true))) (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const T))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const C)) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const T)))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)))) s))\<or>((formEval (andForm (andForm (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const C))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const T)))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)))) s))" by auto moreover { assume c1: "((formEval (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)) s))" have "?P1 s" proof(cut_tac a1 a2 b1 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (andForm (andForm (eqn (IVar (Ident ''x'')) (Const true)) (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const T))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)))) s))" have "?P1 s" proof(cut_tac a1 a2 b1 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (andForm (andForm (neg (eqn (IVar (Ident ''x'')) (Const true))) (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const T))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)))) s))" have "?P2 s" proof(cut_tac a1 a2 b1 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (andForm (andForm (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const C)) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const T)))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)))) s))" have "?P3 s" apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const C)) (eqn (IVar (Ident ''x'')) (Const true))))" in exI, auto) done then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (andForm (andForm (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const C))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const T)))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)))) s))" have "?P1 s" proof(cut_tac a1 a2 b1 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } ultimately have "invHoldForRule s f r (invariants N)" by satx } moreover { assume b1: "(i~=p__Inv0)" have "((formEval (eqn (IVar (Para (Ident ''n'') i)) (Const I)) s))\<or>((formEval (andForm (andForm (eqn (IVar (Ident ''x'')) (Const true)) (eqn (IVar (Para (Ident ''n'') i)) (Const T))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const I)))) s))\<or>((formEval (andForm (andForm (neg (eqn (IVar (Ident ''x'')) (Const true))) (eqn (IVar (Para (Ident ''n'') i)) (Const T))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const I)))) s))\<or>((formEval (andForm (andForm (eqn (IVar (Para (Ident ''n'') i)) (Const C)) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const T)))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const I)))) s))\<or>((formEval (andForm (andForm (neg (eqn (IVar (Para (Ident ''n'') i)) (Const C))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const T)))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const I)))) s))" by auto moreover { assume c1: "((formEval (eqn (IVar (Para (Ident ''n'') i)) (Const I)) s))" have "?P2 s" proof(cut_tac a1 a2 b1 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (andForm (andForm (eqn (IVar (Ident ''x'')) (Const true)) (eqn (IVar (Para (Ident ''n'') i)) (Const T))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const I)))) s))" have "?P1 s" proof(cut_tac a1 a2 b1 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (andForm (andForm (neg (eqn (IVar (Ident ''x'')) (Const true))) (eqn (IVar (Para (Ident ''n'') i)) (Const T))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const I)))) s))" have "?P2 s" proof(cut_tac a1 a2 b1 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (andForm (andForm (eqn (IVar (Para (Ident ''n'') i)) (Const C)) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const T)))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const I)))) s))" have "?P2 s" proof(cut_tac a1 a2 b1 c1, auto) qed then have "invHoldForRule s f r (invariants N)" by auto } moreover { assume c1: "((formEval (andForm (andForm (neg (eqn (IVar (Para (Ident ''n'') i)) (Const C))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const T)))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const I)))) s))" have "?P3 s" apply (cut_tac a1 a2 b1 c1, simp, rule_tac x="(neg (andForm (andForm (andForm (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const T))) (neg (eqn (IVar (Para (Ident ''n'') p__Inv0)) (Const I)))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const T)))) (neg (eqn (IVar (Para (Ident ''n'') i)) (Const I)))))" in exI, auto) done then have "invHoldForRule s f r (invariants N)" by auto } ultimately have "invHoldForRule s f r (invariants N)" by satx } ultimately show "invHoldForRule s f r (invariants N)" by satx qed end
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-} -- | -- Module : Statistics.Distribution.Binomial -- Copyright : (c) 2009 Bryan O'Sullivan -- License : BSD3 -- -- Maintainer : [email protected] -- Stability : experimental -- Portability : portable -- -- The binomial distribution. This is the discrete probability -- distribution of the number of successes in a sequence of /n/ -- independent yes\/no experiments, each of which yields success with -- probability /p/. module Statistics.Distribution.Binomial ( BinomialDistribution -- * Constructors , binomial , binomialE -- * Accessors , bdTrials , bdProbability ) where import Control.Applicative import Data.Aeson (FromJSON(..), ToJSON, Value(..), (.:)) import Data.Binary (Binary(..)) import Data.Data (Data, Typeable) import GHC.Generics (Generic) import Numeric.SpecFunctions (choose,logChoose,incompleteBeta,log1p) import Numeric.MathFunctions.Constants (m_epsilon) import qualified Statistics.Distribution as D import qualified Statistics.Distribution.Poisson.Internal as I import Statistics.Internal -- | The binomial distribution. data BinomialDistribution = BD { bdTrials :: {-# UNPACK #-} !Int -- ^ Number of trials. , bdProbability :: {-# UNPACK #-} !Double -- ^ Probability. } deriving (Eq, Typeable, Data, Generic) instance Show BinomialDistribution where showsPrec i (BD n p) = defaultShow2 "binomial" n p i instance Read BinomialDistribution where readPrec = defaultReadPrecM2 "binomial" binomialE instance ToJSON BinomialDistribution instance FromJSON BinomialDistribution where parseJSON (Object v) = do n <- v .: "bdTrials" p <- v .: "bdProbability" maybe (fail $ errMsg n p) return $ binomialE n p parseJSON _ = empty instance Binary BinomialDistribution where put (BD x y) = put x >> put y get = do n <- get p <- get maybe (fail $ errMsg n p) return $ binomialE n p instance D.Distribution BinomialDistribution where cumulative = cumulative instance D.DiscreteDistr BinomialDistribution where probability = probability logProbability = logProbability instance D.Mean BinomialDistribution where mean = mean instance D.Variance BinomialDistribution where variance = variance instance D.MaybeMean BinomialDistribution where maybeMean = Just . D.mean instance D.MaybeVariance BinomialDistribution where maybeStdDev = Just . D.stdDev maybeVariance = Just . D.variance instance D.Entropy BinomialDistribution where entropy (BD n p) | n == 0 = 0 | n <= 100 = directEntropy (BD n p) | otherwise = I.poissonEntropy (fromIntegral n * p) instance D.MaybeEntropy BinomialDistribution where maybeEntropy = Just . D.entropy -- This could be slow for big n probability :: BinomialDistribution -> Int -> Double probability (BD n p) k | k < 0 || k > n = 0 | n == 0 = 1 -- choose could overflow Double for n >= 1030 so we switch to -- log-domain to calculate probability | n < 1000 = choose n k * p^k * (1-p)^(n-k) | otherwise = exp $ logChoose n k + log p * k' + log1p (-p) * nk' where k' = fromIntegral k nk' = fromIntegral $ n - k logProbability :: BinomialDistribution -> Int -> Double logProbability (BD n p) k | k < 0 || k > n = (-1)/0 | n == 0 = 0 | otherwise = logChoose n k + log p * k' + log1p (-p) * nk' where k' = fromIntegral k nk' = fromIntegral $ n - k -- Summation from different sides required to reduce roundoff errors cumulative :: BinomialDistribution -> Double -> Double cumulative (BD n p) x | isNaN x = error "Statistics.Distribution.Binomial.cumulative: NaN input" | isInfinite x = if x > 0 then 1 else 0 | k < 0 = 0 | k >= n = 1 | otherwise = incompleteBeta (fromIntegral (n-k)) (fromIntegral (k+1)) (1 - p) where k = floor x mean :: BinomialDistribution -> Double mean (BD n p) = fromIntegral n * p variance :: BinomialDistribution -> Double variance (BD n p) = fromIntegral n * p * (1 - p) directEntropy :: BinomialDistribution -> Double directEntropy d@(BD n _) = negate . sum $ takeWhile (< negate m_epsilon) $ dropWhile (not . (< negate m_epsilon)) $ [ let x = probability d k in x * log x | k <- [0..n]] -- | Construct binomial distribution. Number of trials must be -- non-negative and probability must be in [0,1] range binomial :: Int -- ^ Number of trials. -> Double -- ^ Probability. -> BinomialDistribution binomial n p = maybe (error $ errMsg n p) id $ binomialE n p -- | Construct binomial distribution. Number of trials must be -- non-negative and probability must be in [0,1] range binomialE :: Int -- ^ Number of trials. -> Double -- ^ Probability. -> Maybe BinomialDistribution binomialE n p | n < 0 = Nothing | p >= 0 || p <= 1 = Just (BD n p) | otherwise = Nothing errMsg :: Int -> Double -> String errMsg n p = "Statistics.Distribution.Binomial.binomial: n=" ++ show n ++ " p=" ++ show p ++ "but n>=0 and p in [0,1]"
# Contains all helper functions for Tmatrix module using LinearAlgebra """ Calculate dot product for two vectors. # I made this function because the "dot" function in LinearAlgebra package doesn't work as expected for complex vectors. Parameters A, B : two vectors # Returns scalar dot product """ function vector_dot_product(A, B) return sum(A .* B) end """ Create a meshgrid, to be used with numerical integrals. The meshgrid created is following this rule: x_grid[dim1,dim2] dim1 corresponds to x index dim2 corresponds to y index """ function meshgrid(x, y) x_grid = repeat(x, 1, length(y)) y_grid = repeat(y', length(x), 1) return x_grid, y_grid end """ Create meshgrid of θ and ϕ """ function meshgrid_θ_ϕ( n_θ_points, n_ϕ_points; min_θ = 1e-16, min_ϕ = 1e-16, rotationally_symmetric = false, ) #TODO can avoid min values w full algebra θ_1D_array = LinRange(min_θ, π, n_θ_points) ϕ_1D_array = LinRange(min_ϕ, 2π, n_ϕ_points) if rotationally_symmetric θ_array = collect(θ_1D_array) ϕ_array = zeros(size(θ_array)) else θ_array, ϕ_array = meshgrid(θ_1D_array, ϕ_1D_array) end return θ_array, ϕ_array end """ Create a single index from m and n We fill the index like this: `idx = 0 for n = 1:n_max for m = -n:n global idx idx += 1 end end` """ function single_index_from_m_n(m::Int, n::Int) return n * (n + 1) + m end """ Get the maximum single index, given the maximum n. """ function get_max_single_index_from_n_max(n_max::Int) return single_index_from_m_n(n_max, n_max) end """ Multiply the integrand by the `dS` element, which equals r²sin(θ) """ function surface_integrand( integrand::AbstractVecOrMat{C}, r_array::AbstractVecOrMat{R}, θ_array::AbstractVecOrMat{R}, ) where {R <: Real, C <: Complex{R}} return integrand .* r_array .^ 2 .* sin.(θ_array) end """ Multiply the integrand by the `dS` element, which equals r²sin(θ) """ function surface_integrand( integrand::AbstractVecOrMat{R}, r_array::AbstractVecOrMat{R}, θ_array::AbstractVecOrMat{R}, ) where {R <: Real} return integrand .* r_array .^ 2 .* sin.(θ_array) end """ Multiply the integrand by the `dS` element, which equals r²sin(θ) """ function surface_integrand( integrand::AbstractVecOrMat{Matrix{C}}, r_array::AbstractVecOrMat{R}, θ_array::AbstractVecOrMat{R}, ) where {R <: Real, C <: Complex{R}} return integrand .* r_array .^ 2 .* sin.(θ_array) end """ Multiply the integrand by the `dS` element, which equals r²sin(θ) """ function surface_integrand( integrand::AbstractVecOrMat{Matrix{R}}, r_array::AbstractVecOrMat{R}, θ_array::AbstractVecOrMat{R}, ) where {R <: Real, C <: Complex{R}} return integrand .* r_array .^ 2 .* sin.(θ_array) end """ Save T-matrix to HDF5 file, with fields "Tmatrix_real_CELES_convention" and "Tmatrix_imag_CELES_convention" """ function save_Tmatrix_to_HDF5_file(T, HDF5_filename) h5write(HDF5_filename, "Tmatrix_real_CELES_convention", Float64.(real(T))) # TODO: can we store BigFloat in HDF5? I converted to `Float64` because I couldn't read the file when I stored BigFloat h5write(HDF5_filename, "Tmatrix_imag_CELES_convention", Float64.(imag(T))) end # getting indices of T-matrix """ Get 2D array, first and second columns are n and m values, respectively. m = -n : 1 : +n n will be the repeated value of input """ function get_n_m_array_given_n(n) return hcat(repeat([n], 2 * n + 1), (-n):n) end """ Get 2D array, first and second columns are n and m values, respectively. This is looping `get_n_m_array_given_n` over all n = 1:1:n_max """ function get_n_m_array_given_n_max(n_max) return vcat(get_n_m_array_given_n.(1:n_max)...) end """ Get 2D array, first, second and third columns are n, m, and idx values, respectively. The idx value is just the index of the row. """ function get_n_m_idx_array_given_n_max(n_max) nm_array = get_n_m_array_given_n_max(n_max) return hcat(nm_array, 1:size(nm_array, 1)) end """ Get 4 matrices for m, n, m_, n_, corresponding to rank and order of incident and scattered VSWF, represented by elements of T-matrix ## Arguments n_max : Int, determine the size of the T-matrix ## Returns m_matrix, n_matrix, m__matrix, n__matrix : each is a square matrix """ function get_m_n_m__n__matrices_for_T_matrix(n_max) n_m_idx = get_n_m_idx_array_given_n_max(n_max) n_array = n_m_idx[:, 1] m_array = n_m_idx[:, 2] idx_array = n_m_idx[:, 3] idx_max = idx_array[end] idx_matrix = repeat(idx_array, 1, idx_max) idx__matrix = repeat(idx_array', idx_max, 1) n_matrix = n_array[idx_matrix] m_matrix = m_array[idx_matrix] n__matrix = n_array[idx__matrix] m__matrix = m_array[idx__matrix] return m_matrix, n_matrix, m__matrix, n__matrix end """ using for loops, Get 4 matrices for m, n, m_, n_, corresponding to rank and order of incident and scattered VSWF, represented by elements of T-matrix """ function get_m_n_m__n__matrices_for_T_matrix_with_forloop(n_max) idx_max = Tmatrix.get_max_single_index_from_n_max(n_max) n_matrix = zeros(Int, idx_max, idx_max) m_matrix = zeros(Int, idx_max, idx_max) n__matrix = zeros(Int, idx_max, idx_max) m__matrix = zeros(Int, idx_max, idx_max) idx = 0 for n in 1:n_max for m in (-n):n idx += 1 idx_ = 0 for n_ in 1:n_max for m_ in (-n_):n_ idx_ += 1 m_matrix[idx, idx_] = m n_matrix[idx, idx_] = n m__matrix[idx, idx_] = m_ n__matrix[idx, idx_] = n_ end end end end return m_matrix, n_matrix, m__matrix, n__matrix end """ Create m,n,m_,n_ matrices with for loop, and compare the result with `get_m_n_m__n__matrices_for_T_matrix` """ function validate_get_m_n_m__n__matrices_for_T_matrix(n_max) m_matrix, n_matrix, m__matrix, n__matrix = get_m_n_m__n__matrices_for_T_matrix_with_forloop(n_max) _m_matrix, _n_matrix, _m__matrix, _n__matrix = get_m_n_m__n__matrices_for_T_matrix(n_max) println(_n_matrix == n_matrix) println(_m_matrix == m_matrix) println(_n__matrix == n__matrix) println(_m__matrix == m__matrix) end ####################### # TOBE moved to a new package for trapezoidal integraion, that will be compatible with autodiff """ 1D numerical integral using trapezoidal rule x and y are 1D arrays """ #TODO rename to not elzouka lol function trapz_ELZOUKA( x::AbstractVector{R}, y::AbstractVector{N}, ) where {R <: Real, N <: Number} # TODO: small error if compared with Trapz.trapz base = x[2:end] - x[1:(end - 1)] av_height = (y[2:end] + y[1:(end - 1)]) / 2 areas = base .* av_height total_area = sum(areas) return total_area end """ 2D numerical integral using trapezoidal rule x and y are 1D arrays, z is 2D array """ function trapz_ELZOUKA( x::AbstractVector{R}, y::AbstractVector{R}, z::AbstractMatrix{N}, ) where {R <: Real, N <: Number} integrand_wrt_x = trapz_ELZOUKA.(eachcol(repeat(x, 1, size(z, 2))), eachcol(z)) return trapz_ELZOUKA(y, integrand_wrt_x) end ####################### # Calculate orientation-averaged sscattering, extinction and absorption cross sections. """ calculate orientation averaged scattering cross section given a T-matrix and a wavevector. Input T-matrix can be a complex square matrix or a concatenation of separate real and imag parts of T-matrix """ function get_OrentationAv_scattering_CrossSection_from_Tmatrix( T::AbstractMatrix, k1::C, ) where {C <: Complex} if size(T)[1] == size(T)[2] # if T-matrix is a square matrix, then T-matrix is complex return real(2 * pi / k1^2 * sum(T .* conj(T))) elseif size(T)[1] == size(T)[2] / 2 # if T-matrix has number of columns double the number of rows, then T-matrix is hcat() of real and imag parts of Tmatrix return get_OrentationAv_scattering_CrossSection_from_Tmatrix_SeparateRealImag( T, real(k1), imag(k1), ) end end """ calculate orientation averaged scattering cross section given a T-matrix, wavelength and optical properties of surrounding. Input T-matrix can be a complex square matrix or a concatenation of separate real and imag parts of T-matrix """ function get_OrentationAv_scattering_CrossSection_from_Tmatrix( T::AbstractMatrix, wl_or_freq_input::R, input_unit::String, Eps_r_1::C, Mu_r_1::C, ) where {C <: Complex, R <: Real} return get_OrentationAv_scattering_CrossSection_from_Tmatrix( T, get_WaveVector( wl_or_freq_input; input_unit = input_unit, Eps_r = Eps_r_1, Mu_r = Mu_r_1, ), ) end """ calculate orientation averaged scattering cross section given a T-matrix and a wavevector. This works for "_SeparateRealImag" """ function get_OrentationAv_scattering_CrossSection_from_Tmatrix_SeparateRealImag( T::AbstractMatrix{R}, k1_r::R, k1_i::R, ) where {R <: Real} T_r, T_i = Tmatrix.separate_real_imag(T) T_by_conjT_sum = sum(complex_multiply.(T_r, T_i, T_r, -T_i)) k1_squared = complex_multiply(k1_r, k1_i, k1_r, k1_i) two_pi_over_k1_squared = complex_divide(2 * pi, 0, k1_squared[1], k1_squared[2]) return complex_multiply( two_pi_over_k1_squared[1], two_pi_over_k1_squared[2], T_by_conjT_sum[1], T_by_conjT_sum[2], )[1] end """ calculate orientation averaged extinction cross section given a T-matrix and a wavevector. """ function get_OrentationAv_extinction_CrossSection_from_Tmatrix( T::AbstractMatrix, k1::C, ) where {C <: Complex} if size(T)[1] == size(T)[2] # if T-matrix is a square matrix, then T-matrix is complex return real(-2 * pi / k1^2 * tr(real(T))) elseif size(T)[1] == size(T)[2] / 2 # if T-matrix has number of columns double the number of rows, then T-matrix is hcat() of real and imag parts of Tmatrix return get_OrentationAv_extinction_CrossSection_from_Tmatrix_SeparateRealImag( T, real(k1), imag(k1), ) end end """ calculate orientation averaged extinction cross section given a T-matrix and a wavevector. This works for "_SeparateRealImag" """ function get_OrentationAv_extinction_CrossSection_from_Tmatrix_SeparateRealImag( T::AbstractMatrix{R}, k1_r::R, k1_i::R, ) where {R <: Real} T_r, T_i = Tmatrix.separate_real_imag(T) k1_squared = complex_multiply(k1_r, k1_i, k1_r, k1_i) two_pi_over_k1_squared = complex_divide(2 * pi, 0, k1_squared[1], k1_squared[2]) return -two_pi_over_k1_squared[1] * tr(T_r) end """ calculate orientation averaged absorption cross section given a T-matrix and a wavevector. """ function get_OrentationAv_absorption_CrossSection_from_Tmatrix( T::AbstractMatrix, k1::C, ) where {C <: Complex} return get_OrentationAv_extinction_CrossSection_from_Tmatrix(T, k1) - get_OrentationAv_scattering_CrossSection_from_Tmatrix(T, k1) end """ calculate orientation averaged absorption cross section given a T-matrix and a wavevector. This works for "_SeparateRealImag" """ function get_OrentationAv_absorption_CrossSection_from_Tmatrix_SeparateRealImag( T::AbstractMatrix{R}, k1_r::R, k1_i::R, ) where {R <: Real} return get_OrentationAv_extinction_CrossSection_from_Tmatrix_SeparateRealImag( T, k1_r, k1_i, ) - get_OrentationAv_scattering_CrossSection_from_Tmatrix_SeparateRealImag( T, k1_r, k1_i, ) end """ calculate orientation averaged emissivity cross section given a T-matrix and a wavevector. `particle_surface_area` has to be in units consistent with wavevector units. If waveevctor unit is per m, then the particle surface area has to be in m^2 """ function get_OrentationAv_emissivity_from_Tmatrix( T::AbstractMatrix, k1::C, particle_surface_area::R, ) where {R <: Real, C <: Complex} return get_OrentationAv_absorption_CrossSection_from_Tmatrix(T, k1) * 4 / particle_surface_area end """ calculate orientation averaged emissivity cross section given a T-matrix and a wavevector. This works for "_SeparateRealImag" `particle_surface_area` has to be in units consistent with wavevector units. If waveevctor unit is per m, then the particle surface area has to be in m^2 """ function get_OrentationAv_emissivity_from_Tmatrix_SeparateRealImag( T::AbstractMatrix{R}, k1_r::R, k1_i::R, particle_surface_area::R, ) where {R <: Real} return get_OrentationAv_absorption_CrossSection_from_Tmatrix_SeparateRealImag( T, k1_r, k1_i, ) * 4 / particle_surface_area end """ calculate orientation averaged emissivity cross section given a T-matrix, wavelength and optical properties of surrounding. This works for "_SeparateRealImag" `particle_surface_area` has to be in units consistent with wavevector units. If waveevctor unit is per m, then the particle surface area has to be in m^2 """ function get_OrentationAv_emissivity_from_Tmatrix_SeparateRealImag( T::AbstractMatrix{R}, wl_or_freq_input::R, input_unit::String, Eps_r_r_1::R, Eps_r_i_1::R, Mu_r_r_1::R, Mu_r_i_1::R, particle_surface_area::R, ) where {R <: Real} k1_complex = get_WaveVector( wl_or_freq_input; input_unit = input_unit, Eps_r = Complex(Eps_r_r_1, Eps_r_i_1), Mu_r = Complex(Mu_r_r_1, Mu_r_i_1), ) return get_OrentationAv_absorption_CrossSection_from_Tmatrix_SeparateRealImag( T, k1_r, k1_i, ) * 4 / particle_surface_area end
function S=PSNR(sss,aaa) [m n p]=size(sss); A=double(sss); B=double(aaa); sumaDif=0; maxI=m*n*max(max(A.^2)); for u=1:m for v=1:n sumaDif=sumaDif+(A(u,v)-B(u,v))^2; end end if (sumaDif==0) sumaDif=1; end S=maxI/sumaDif; S=10*log10(S);
subroutine ttable c----------------------------------------------------------------------- c this subroutine is a secondary driver. the subroutine is one c large loop within which the source depth is incremented by dz c on each pass. the section of the velocity model within this dz c increment is placed in the work spaces contained in the common c block called window. this window is then used when ttime is called c to increment the /upward/ arrays to travel times and distances to c this source depth. c----------------------------------------------------------------------- include 'switch.common' include 'table.common' include 'surface.common' include 'control.common' include 'window.common' character bnorm,revs,shad parameter(bnorm='d',revs='r',shad='s') parameter(flaglvz=1.0e37) parameter(dzcut=1.0e-4) ip=1 z=0. c--first define branch for surface focus branch(1)=bnorm do 50 i=2,ns if(t(i).gt.flaglvz) then branch(i)=shad elseif(x(i).gt.x(i-1))then branch(i)=bnorm else branch(i)=revs endif 50 continue call gridtp(z,p,t,x,branch,dx,ns) c--loop on depths do 100 iz=1,nz-1 z=float(iz)*dz c--test for special case on first pass if(iz.eq.1) then vwork(1) = v(1) dwork(1) = d(1) else vwork(1)=vwork(nwindow) dwork(1)=dwork(nwindow) endif c--find window and store in work spaces c--test for endpoint if(ip.ge.ns) then print 1000 return endif c--back up the pointer if necessary. 55 if(z.gt.d(ip)) go to 60 ip=ip-1 go to 55 60 continue ip=ip+1 k=2 65 if((z.lt.d(ip)).or.(abs(d(ip)-z).lt.dzcut)) go to 70 vwork(k)=v(ip) dwork(k)=d(ip) ip=ip+1 k=k+1 c--is this a legal depth point. if not exit gracefully if(ip.eq.ns) then if(abs(z-d(ip)).le.dzcut) then vwork(k)=v(ip) dwork(k)=d(ip) go to 75 else print 1000 1000 format('/////non-fatal error. nz and dz are not', $ 'consistent. program exits gracefully/////') return endif endif go to 65 70 continue c--back the pointer up one so that this source point lies c--between d(ip) and d(ip+1). ip = ip - 1 c--interpolate and add one point to window corresponding to the c--remaining increment to the source depth if this is not too close c--to the next velocity model point if((d(ip+1)-z).lt.dzcut) then vwork(k)=v(ip+1) dwork(k)=d(ip+1) ip=ip+1 else vwork(k)=v(ip)+(z-d(ip))*(v(ip+1)-v(ip)) $ /(d(ip+1)-d(ip)) dwork(k)=z endif 75 nwindow=k c--calculate the travel time curve call ttime(ip) call gridtp(z,ptab,ttab,xtab,branch,dx,ntab) 100 continue return end c $Id$