import { Add, Multiply, Succ, _0, _1, _3 } from './nat'; import { Op, Rewrite, ChainRewrites, Flip, Equation, Refl, VerifyEquation, assert } 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']>; }; export namespace spec { export type commutativity = [ assert>>, assert>>, ] export type associativity = [ assert>>, assert>>, ] } } export namespace multiplication { export type Identity = Rewrite, A>; export type IdentityR = Rewrite, A>; export type Mul_Add = Rewrite, B>, Add>>; export type Mul_AddR = Rewrite>, Add>>; export type Commutativity = Rewrite, Multiply>; export interface Comm_Base { type: 'rewrite', left: Equation, Multiply>; // 1 * b = b * 1 right: ChainRewrites<[ IdentityR, // b = b + 0 Identity, // b = b Refl, // true ], this['left']>; }; export interface Comm_Inductive { type: 'rewrite', left: Equation, B>, Multiply>>; // succ(a)*b = b*succ(a) right: ChainRewrites<[ Mul_Add, // a + a*b = b*succ(a) Mul_AddR, // a + a*b = a + b*a Commutativity, // a + a*b = a + a*b Refl>>, // true ], this['left']>; }; export namespace spec { export type commutativity = [ assert>>, assert>>, ] } }