From efc0358c1e2b52308d3df68aa713cef5dc6e6bfe Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 15 Dec 2023 22:36:03 +0530 Subject: refactor: moves stuff around --- src/index.ts | 236 ----------------------------------------------------------- 1 file changed, 236 deletions(-) delete mode 100644 src/index.ts (limited to 'src/index.ts') diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 4a00438..0000000 --- a/src/index.ts +++ /dev/null @@ -1,236 +0,0 @@ -import { Add, Multiply, Succ, _0, _1, _3 } from './nat'; -import { Op, Rewrite, ChainRewrites, Sym, Equation, Refl, VerifyEquation, assert, Subst, ApplyRewrite, Evaluate, OpToStr } from './util'; - -export namespace addition { - // Identity - export type Identity = Rewrite, A>; - export type IdentityR = Rewrite, A>; - - export type SuccLemma = Rewrite, B>, Succ>> - export type SuccLemmaR = 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, - ], this['left']>; - }; - export interface Comm_Inductive_Proof { - type: 'rewrite', - left: Equation, B>, Add>>; // succ(a) + b = b + succ(a) - right: ChainRewrites<[ - SuccLemma, // succ(a + b) = b + succ(a) - Commutativity, // succ(b + a) = b + succ(a) - SuccLemmaR, // succ(b + a) = succ(b + a) - Refl, - ], 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, - ], 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<[ - SuccLemma, // succ(a + b) + c = succ(a) + (b + c) - SuccLemma>, // succ(a + b) + c = succ(a + (b + c)) - SuccLemma, C>, // succ((a + b) + c) = succ(a + (b + c)) - Associativity, // succ(a + (b + c)) = succ(a + (b + c)) - Refl, - ], this['left']>; - }; - - export namespace spec { - export type associativity = [ - assert>>, - assert>>, - ] - } - - // Rearrange - export interface Rearrange_Proof { - type: 'rewrite', - left: Equation, Add>, Add, D>>>; // (a + b) + (c + d) = a + ((b + c) + d) - right: ChainRewrites<[ - Associativity>, // a + (b + (c + d)) = a + ((b + c) + d) - Associativity, // a + (b + (c + d)) = a + (b + (c + d)) - Refl, - ], this['left']>; - }; - export namespace spec { - export type rearrange = [ - assert>>, - ] - } -} - -export namespace multiplication { - // Identity - export type Identity = Rewrite, A>; - export type IdentityR = Rewrite, A>; - - export type SuccLemma = Rewrite, B>, Add>>; - export type SuccLemmaR = 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, - ], this['left']>; - }; - export interface Comm_Inductive_Proof { - type: 'rewrite', - left: Equation, B>, Multiply>>; // succ(a)*b = b*succ(a) - right: ChainRewrites<[ - SuccLemma, // b + a*b = b*succ(a) - SuccLemmaR, // b + a*b = b + b*a - Commutativity, // b + a*b = b + a*b - Refl, - ], 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.SuccLemma<_0, B>, // succ(0 + b)*c = c + b*c - addition.IdentityR, // succ(b)*c = c + b*c - SuccLemma, // c + b*c = c + b*c - Refl, - ], 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.SuccLemma, // succ(a + b)*c = succ(a)*c + b*c - SuccLemma, C>, // c + (a + b)*c = succ(a)*c + b*c - SuccLemma, // 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, - ], 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, - ], 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<[ - SuccLemma, // (b + a*b)*c = succ(a) * (b*c) - Distributivity, C>, // b*c + (a*b)*c = succ(a) * (b*c) - SuccLemma>, // b*c + (a*b)*c = b*c + a*(b*c) - Associativity, // b*c + a*(b*c) = b*c + a*(b*c) - Refl, - ], this['left']>; - }; - export namespace spec { - export type associativity = [ - assert>>, - assert>>, - ] - } -} - -export namespace equation { - type F = { op: 'F', a: X }; - - export type Reflexivity = Rewrite, 'true'>; - - export type Symmetry = Rewrite, Equation>; - - export type Congruence = Rewrite, Equation, F>>; - - export type SubstituteEq> = Rewrite - export interface SubstituteEq_Proof { - type: 'rewrite', - known: { - 'a = b': Equation, - }, - left: Equation, F>; // f(a) = f(b) - right: ChainRewrites<[ - Sym>, // a = b - SubstituteEq, // b = b - Reflexivity, - ], this['left']>; - }; - export namespace spec { - export type substitution = [ - assert>>, - ] - } - - export interface Transitivity_Proof { - type: 'rewrite', - known: { - 'a = b': Equation, - 'b = c': Equation, - }, - left: Equation, Equation>; // (a = b) = (b = c) - right: ChainRewrites<[ - SubstituteEq, // (b = b) = (b = c) - SubstituteEq>>, // (b = b) = (c = b) - Reflexivity, // true = (b = b) - Reflexivity, // true = true - Reflexivity<'true'>, - ], this['left']>; - }; - export namespace spec { - export type transitivity = [ - assert>>, - ] - } -} -- cgit v1.3.1