import { Add, Multiply, Succ, _0 } from './nat'; import { Op, Rewrite, ChainRewrites, Flip, Equation, Refl } from './util'; export namespace addition { export type Identity = Rewrite, A>; export type IdentityR = Rewrite, A>; export type SumSucc1 = Rewrite, B>, Succ>> export type SumSucc2 = Rewrite>, Succ>> /// Sum commutativity export type Commutativity = Rewrite, Add>; export interface Comm_Base { type: 'rewrite', left: Equation, Add>; // 0 + b = b + 0 right: ChainRewrites<[ IdentityR, // b = b + 0 Flip>, // b + 0 = b + 0 Refl>, // true ], this['left']>; }; export interface Comm_Inductive { type: 'rewrite', left: Equation, B>, Add>>; // succ(a) + b = b + succ(a) right: ChainRewrites<[ SumSucc1, // succ(a + b) = b + succ(a) Commutativity, // succ(b + a) = b + succ(a) SumSucc2, // succ(b + a) = succ(b + a) Refl>>, // true ], this['left']>; }; // Sum associativity export type Associativity = Rewrite, C>, Add>>; export interface Assoc_Base { type: 'rewrite', left: Equation, C>, Add<'0', Add>>; // (0 + b) + c = 0 + (b + c) right: ChainRewrites<[ Commutativity<'0', B>, // (b + 0) + c = 0 + (b + c) Identity, // b + c = 0 + (b + c) IdentityR>, // b + c = b + c Refl>, // true ], this['left']>; }; export interface Assoc_Inductive { type: 'rewrite', left: Equation, B>, C>, Add, Add>>; // (succ(a) + b) + c = succ(a) + (b + c) right: ChainRewrites<[ SumSucc1, // succ(a + b) + c = succ(a) + (b + c) SumSucc1>, // succ(a + b) + c = succ(a + (b + c)) SumSucc1, C>, // succ((a + b) + c) = succ(a + (b + c)) Associativity, // succ(a + (b + c)) = succ(a + (b + c)) Refl>>>, // true ], this['left']>; }; }