<<

The MathScheme Library: Some Preliminary Experiments

Jacques Carette, William M. Farmer, Filip Jeremic, Vincent Maccio, Russell O’Connor and Quang M. Tran McMaster University

CICM 2011, Bertinoro, Italy

22nd July 2011 Overview With MathScheme, we wish to significantly advance the capabilities of mechanized systems. To achieve this, we need to (at least):

I Learn from previous systems, I Learn from experiments whether our own ideas will work. Here we present 3 such experiments in “library building”: Abstract Theories, Concrete Theories and Applied Experimental -up

I Pick a topic which needs implemented, I Collect ideas for implementation (old and new), I Build enough to be be able to see patterns, I Evaluate results. See WiP paper for a lot more details.

Carette, Farmer, et al MathScheme Library: Experiments 2/7 More precisely: the presentations of theories are related. Main Idea: Tiny Theories. Build up “network” one concept at a time.

Experiment 1: Abstract Theories The Theories of mathematics are highly related: := combine , over Semirng F i e l d := combine DivisionRing , CommutativeRing over Ring

Carette, Farmer, et al MathScheme Library: Experiments 3/7 Main Idea: Tiny Theories. Build up “network” one concept at a time.

Experiment 1: Abstract Theories The Theories of mathematics are highly related: Ring := combine Rng, SemiRing over Semirng F i e l d := combine DivisionRing , CommutativeRing over Ring More precisely: the presentations of theories are related.

Carette, Farmer, et al MathScheme Library: Experiments 3/7 Experiment 1: Abstract Theories The Theories of mathematics are highly related: Ring := combine Rng, SemiRing over Semirng F i e l d := combine DivisionRing , CommutativeRing over Ring More precisely: the presentations of theories are related. Main Idea: Tiny Theories. Build up “network” one concept at a time.

Carette, Farmer, et al MathScheme Library: Experiments 3/7 Experiment 1: Abstract Theories The Theories of mathematics are highly related: Ring := combine Rng, SemiRing over Semirng F i e l d := combine DivisionRing , CommutativeRing over Ring More precisely: the presentations of theories are related. Main Idea: Tiny Theories. Build up “network” one concept at a time.

Empty := Theory {} Carrier := Empty extended by { U: type } PointedCarrier := Carrier extended by { e : U } UnaryOperation := Carrier extended by { prime : U −> U } PointedUnarySystem := combine UnaryOperation , PointedCarrier over C a r r i e r DoublyPointed := PointedCarrier extended by { e2 : U } BinaryOperation := Carrier extended by { ∗∗ :(U,U) −> U } := BinaryOperation [∗∗ |−> ∗] CarrierS := Carrier[U |−> S] MultiCarrier := combine Carrier , CarrierS over Empty UnaryRelation := Carrier extended by { R:U?} BinaryRelation := Carrier extended by { R:(U,U)? } InvolutiveUnarySystem := UnaryOperation extended by { axiom i n v o l u t i v e p r i m e : f o r a l l x:(prime). prime(prime x) = x } := Magma extended by { axiom associative ∗ : associative(( ∗ )) }

Carette, Farmer, et al MathScheme Library: Experiments 3/7 Experiment 1: Abstract Theories The Theories of mathematics are highly related: Ring := combine Rng, SemiRing over Semirng F i e l d := combine DivisionRing , CommutativeRing over Ring More precisely: the presentations of theories are related. Main Idea: Tiny Theories. Build up “network” one concept at a time.

LeftNearRing := combine LeftNearSemiring , AdditiveGroup over AdditiveMonoid LeftSemirng := combine LeftNearSemiring , AdditiveCommutativeMonoid over AdditiveMonoid LeftRng := combine LeftNearRing , LeftSemirng over LeftNearSemiring LeftSemiring := combine LeftSemirng , Monoid1 over Semigroup L e f t R i n g := combine LeftRng , LeftSemiring over LeftSemirng Semirng := LeftSemirng extended by { axiom rightDistributive ∗ + : leftDistributive((flipuc (( ∗ ) ) ) , ( + ) ) } Rng := combine LeftRng , Semirng over LeftSemirng SemiRing := combine LeftSemiring , Semirng over LeftSemirng Dioid := SemiRing extended by { axiom i d e m p o t e n t + : ((+)) } Ring := combine Rng, SemiRing over Semirng

Carette, Farmer, et al MathScheme Library: Experiments 3/7 Experiment 1: Abstract Theories The Theories of mathematics are highly related: Ring := combine Rng, SemiRing over Semirng F i e l d := combine DivisionRing , CommutativeRing over Ring More precisely: the presentations of theories are related. Main Idea: Tiny Theories. Build up “network” one concept at a time.

LeftNearSemiring := Theory { U: type ; ∗ :(U,U) −> U; + : (U, U) −> U; 0 : U; axiom rightIdentity + 0 := f o r a l l x : U. x + 0 = x ; axiom leftIdentity + 0 := f o r a l l x : U. 0 + x = x ; axiom leftDistributive ∗ + := f o r a l l x , y , z : U. x ∗ ( y + z ) = ( x ∗ y ) + ( x ∗ z ) ; axiom l e f t 0 := f o r a l l x : U. 0 ∗ x = 0 ; axiom associative + := f o r a l l x,y,z : U. (x+y)+z=x+(y+z); axiom associative ∗ := f o r a l l x , y , z : U. ( x ∗ y ) ∗ z = x ∗ ( y ∗ z ) }

Carette, Farmer, et al MathScheme Library: Experiments 3/7 VectorSpace ModalAlgebra

RModule PreModalAlgebra

RightRModule CommutativeRingAction LeftRModule BooleanAlgebra Necessity

RightRingAction LeftRingAction ModularOrtholattice GoedelAlgebra

PreRightRingAction IntegralDomain DivisionRing PreLeftRingAction BooleanRing KleeneAlgebra Orthomodularlattice KleeneLattice HeytingAlgebra

MultRightMonoidAction PrimeAdditiveGroup Domain CommutativeRing MultMonoidAction StarSemiring Ortholattice KleeneLatticeP HeytingAlgebraP

AbelianGroup Ring LeftMonoid1Action Dioid PreStarSemiring PreOrtholattice InvolutiveUnarySystem BoundedDistributiveLattice

LeftRing Rng SemiRing NonassociativeRing Star ComplementedLattice PointedUnarySystem InvUnary BoundedModularLattice DistributiveLattice

RightMonoid1Action LeftRng LeftSemiring Semirng NonassociativeNondistributiveRing BoundedLattice UnaryOperation ModularLattice

Group1 LeftNearRing LeftSemirng AbelianAdditiveGroup BoundedMeetLattice BoundedJoinLattice ImplicationMagma

RightGroupAction LeftGroupAction LeftNearSemiring AdditiveGroup BoundedJoinSemilattice

RightMonoidAction LeftMonoidAction Monoid1 CommutativeAdditiveMagma DualSemilattices BoundedMeetSemilattice

MoufangLoop RawGroup LeftNearSemiringoid AdditiveCommutativeMonoid CommutativeMonoid1 AdditiveMagma JoinSemilattice

PreRightMonoidAction Loop PreLeftMonoidAction TraceMonoid AdditiveMonoid CommutativeMonoid MeetSemilattice Chain

QuasiGroup LeftSemigroupAction LeftGroup Sloop CommutativeBand MeetDirectoid TotalOrder EquivalenceRelation

RightSemigroupAction RightMagmaAction RightQuasiGroup LeftMagmaAction Unital LeftLoop RightMonoid PointedSteiner CommutativeSemigroup Squag Band Quandle IdempotentUpDirectedSet TotalPreorder PartialOrder TildePreorder

RightMagmaActionP RightBiMagma LeftMagmaActionP LeftQuasiGroup LeftUnital LeftPointAction RightPointAction RightUnital Semigroup PointedCommutativeMagma Steiner IdempotentMagma Rack UpDirectedSet SimpleGraph Preorder

RightOperation Pair LeftOperation Sink LeftBiMagma PointedMagma DoublyPointed CommutativeMagma DirectedSet FunctionSpace Heap IdempotentSemiheap Digraph Graph ReflexiveOrderRelation TransitiveOrderRelation

BasicBool MultiCarrier PreSink LeftDivisionMagma PointedCarrier RightDistributiveMagma FunctionalComposition FunctionalIdentity Semiheap PseudoGraph OrderRelation

Not Or And NatAdd UnaryRelation CarrierS SubType Magma FunctionCarrier TernaryOperation BinaryRelation

Bool FieldTerm MonoidTerm Nat NatAddTerm One Carrier

Empty

Base

Carette, Farmer, et al MathScheme Library: Experiments 4/7 I but many concrete structures are parametric, and most extensions are conservative.

Experiment 2: Concrete Theories aka Concrete Structures Exact same idea as for Abstract Theories

Carette, Farmer, et al MathScheme Library: Experiments 5/7 Experiment 2: Concrete Theories aka Concrete Structures Exact same idea as for Abstract Theories

I but many concrete structures are parametric, and most extensions are conservative.

Carette, Farmer, et al MathScheme Library: Experiments 5/7 Experiment 2: Concrete Theories aka Concrete Structures Exact same idea as for Abstract Theories

I but many concrete structures are parametric, and most extensions are conservative.

B i t Base := Empty extended conservatively by { I n d u c t i v e b i t | 0 : b i t | 1 : b i t } or B i t B a s e Abstract := Empty extended by { b i t : type 1 : b i t 0 : b i t axiom : f o r a l l b : b i t . b = 1 or b = 0 axiom : not (1=0) }

Carette, Farmer, et al MathScheme Library: Experiments 5/7 Experiment 2: Concrete Theories aka Concrete Structures Exact same idea as for Abstract Theories

I but many concrete structures are parametric, and most extensions are conservative.

Bit And := B i t B a s e extended conservatively by { b i t and : (bit, bit) −> b i t ; b i t a n d ( x , y ) = case x of { | 0 −> 0 | 1 −> y } } B i t := combine Bit And , Bit Or , Bit Not , B i t Implies , Bit Xor , B i t X n o r over B i t B a s e

Carette, Farmer, et al MathScheme Library: Experiments 5/7 Experiment 2: Concrete Theories aka Concrete Structures Exact same idea as for Abstract Theories

I but many concrete structures are parametric, and most extensions are conservative.

Nat := Empty extended conservatively by { I n d u c t i v e nat z e r o : nat succ : nat −> nat ; } List := Carrier extended conservatively by { I n d u c t i v e l i s t n i l : l i s t cons : U −> l i s t −> l i s t ; } BitCarrier := i n s t a n c e B i t B a s e of C a r r i e r v i a [ b i t |−> U] B i t L i s t := combine List , BitCarrier over C a r r i e r

and of course length, map, zipWith etc.

Carette, Farmer, et al MathScheme Library: Experiments 5/7 I , , substructure, type representing a model, etc.

Experiment 3: Applied Universal Algebra Universal Algebra: study of algebraic structures themselves rather than their models. Uniform Constructions:

Carette, Farmer, et al MathScheme Library: Experiments 6/7 Experiment 3: Applied Universal Algebra Universal Algebra: study of algebraic structures themselves rather than their models. Uniform Constructions:

I homomorphism, term algebra, substructure, type representing a model, etc.

Carette, Farmer, et al MathScheme Library: Experiments 6/7 Experiment 3: Applied Universal Algebra Universal Algebra: study of algebraic structures themselves rather than their models. Uniform Constructions:

I homomorphism, term algebra, substructure, type representing a model, etc.

MonoidTerm := Theory { type MTerm = &Monoid } denotes the inductive term MonoidTerm := Theory { type MTerm = data X . #e : X | #∗ :(X,X) −> X }

Carette, Farmer, et al MathScheme Library: Experiments 6/7 Experiment 3: Applied Universal Algebra Universal Algebra: study of algebraic structures themselves rather than their models. Uniform Constructions:

I homomorphism, term algebra, substructure, type representing a model, etc.

type semigroup = TypeFrom(Semigroup) in the context of a Theory means (i.e. is expanded to) type semigroup = {U: type , ∗ : ( U,U)−>U, associative ∗ : ProofOf ( f o r a l l x , y , z :U . ( x∗y )∗ z = x ∗( y∗ z ) ) }

Carette, Farmer, et al MathScheme Library: Experiments 6/7 Experiment 3: Applied Universal Algebra Universal Algebra: study of algebraic structures themselves rather than their models. Uniform Constructions:

I homomorphism, term algebra, substructure, type representing a model, etc.

MonoidH := Homomorphism(Monoid) means (expands to) MonoidH := Theory { type monoid = TypeFrom(Monoid); A, B : monoid; f : A .U −> B.U; axiom p r e s ∗ : f o r a l l x, y:A.U . f(x A. ∗ y ) = f ( x ) B. ∗ f ( y ) ; axiom p r e s e: f(A.e) =B.e; }

Carette, Farmer, et al MathScheme Library: Experiments 6/7 Experiment 3: Applied Universal Algebra Universal Algebra: study of algebraic structures themselves rather than their models. Uniform Constructions:

I homomorphism, term algebra, substructure, type representing a model, etc.

SubSemigroup := Substructure(Semigroup) means (expands to) SubSemigroup := Theory { type semigroup = TypeFrom(SemiGroup); A : semigroup; V: type ; axiom V <:A.U; axiom c l o s e d ∗ : f o r a l l x,y:V.defined −i n ( x A. ∗ y , V) }

Carette, Farmer, et al MathScheme Library: Experiments 6/7 Conclusion There is a lot of structure in Mathematics, and it can be leveraged to simplify builder’s lives.

Process: 1. Decide on a chunk of mathematics or CS to implement, 2. Implement prototype using proven methods, 3. Once enough done, find patterns, and either

I Use state-of-the-art method to abstract pattern, or I Invent something (and make sure it is semantically sound) 4. Repeat

Carette, Farmer, et al MathScheme Library: Experiments 7/7