import { Add, Multiply, Succ, _0, _1, _3 } from './nat'; import { Op, Rewrite, ChainRewrites, Sym, Equation, Refl, VerifyEquation, assert } from './util'; export namespace addition { // Identity export type Identity = Rewrite, A>; export type IdentityR = Rewrite, A>; export type SumSucc = Rewrite, B>, Succ>> export type SumSuccR = Rewrite>, Succ>> // Commutativity export type Commutativity = Rewrite, Add>; export interface Comm_Base_Proof { type: 'rewrite', left: Equation, Add>; // 0 + b = b + 0 right: ChainRewrites<[ IdentityR, // b = b + 0 Sym>, // b + 0 = b + 0 Refl>, // true ], this['left']>; }; export interface Comm_Inductive_Proof { type: 'rewrite', left: Equation, B>, Add>>; // succ(a) + b = b + succ(a) right: ChainRewrites<[ SumSucc, // succ(a + b) = b + succ(a) Commutativity, // succ(b + a) = b + succ(a) SumSuccR, // succ(b + a) = succ(b + a) Refl>>, // true ], this['left']>; }; export namespace spec { export type commutativity = [ assert>>, assert>>, ] } // Associativity export type Associativity = Rewrite, C>, Add>>; export interface Assoc_Base_Proof { 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_Proof { type: 'rewrite', left: Equation, B>, C>, Add, Add>>; // (succ(a) + b) + c = succ(a) + (b + c) right: ChainRewrites<[ SumSucc, // succ(a + b) + c = succ(a) + (b + c) SumSucc>, // succ(a + b) + c = succ(a + (b + c)) SumSucc, 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 associativity = [ assert>>, assert>>, ] } } export namespace multiplication { // Identity export type Identity = Rewrite, A>; export type IdentityR = Rewrite, A>; export type MulSucc = Rewrite, B>, Add>>; export type MulSuccR = Rewrite>, Add>>; // Commutativity export type Commutativity = Rewrite, Multiply>; export interface Comm_Base_Proof { type: 'rewrite', left: Equation, Multiply>; // 1 * b = b * 1 right: ChainRewrites<[ IdentityR, // b = b * 1 Identity, // b = b Refl, // true ], this['left']>; }; export interface Comm_Inductive_Proof { type: 'rewrite', left: Equation, B>, Multiply>>; // succ(a)*b = b*succ(a) right: ChainRewrites<[ MulSucc, // b + a*b = b*succ(a) MulSuccR, // b + a*b = b + b*a Commutativity, // b + a*b = b + a*b Refl>>, // true ], this['left']>; }; export namespace spec { export type commutativity = [ assert>>, assert>>, ] } // Distributivity export type Distributivity = Rewrite, C>, Add, Multiply>>; export interface Dist_Base_Proof { type: 'rewrite', left: Equation, C>, Add, Multiply>>; // (1 + b)*c = 1*c + b*c right: ChainRewrites<[ IdentityR, // (1 + b)*c = c + b*c addition.SumSucc<_0, B>, // succ(0 + b)*c = c + b*c addition.IdentityR, // succ(b)*c = c + b*c MulSucc, // c + b*c = c + b*c Refl>>, // true ], this['left']>; }; export interface Dist_Inductive_Proof { type: 'rewrite', left: Equation, B>, C>, Add, C>, Multiply>>; // (succ(a) + b)*c = succ(a)*c + b*c right: ChainRewrites<[ addition.SumSucc, // succ(a + b)*c = succ(a)*c + b*c MulSucc, C>, // c + (a + b)*c = succ(a)*c + b*c MulSucc, // c + (a + b)*c = (c + a*c) + b*c Distributivity, // c + (a*c + b*c) = (c + a*c) + b*c addition.Associativity, Multiply>, // (c + a*c) + b*c = (c + a*c) + b*c Refl, Multiply>>>, // true ], this['left']>; }; export namespace spec { export type distributivity = [ assert>>, assert>>, ] } // Associativity export type Associativity = Rewrite, C>, Multiply>>; export interface Assoc_Base_Proof { type: 'rewrite', left: Equation, C>, Multiply<_1, Multiply>>; // (1*b)*c = 1*(b*c) right: ChainRewrites<[ IdentityR, // b*c = 1*(b*c) IdentityR>, // b*c = b*c Refl>, // true ], this['left']>; }; export interface Assoc_Inductive_Proof { type: 'rewrite', left: Equation, B>, C>, Multiply, Multiply>>; // (succ(a)*b)*c = succ(a)*(b*c) right: ChainRewrites<[ MulSucc, // (b + a*b)*c = succ(a) * (b*c) Distributivity, C>, // b*c + (a*b)*c = succ(a) * (b*c) MulSucc>, // b*c + (a*b)*c = b*c + a*(b*c) Associativity, // b*c + a*(b*c) = b*c + a*(b*c) Refl, Multiply>>>, // true ], this['left']>; }; export namespace spec { export type associativity = [ assert>>, assert>>, ] } }