class zero {}; template class succ {}; template class add {}; template class eq { private: eq() {} friend class axiom; }; class axiom { public: template static eq reflexive() { return eq(); } template static eq symmetric( eq ) { return eq(); } template static eq transitive( eq, eq ) { return eq(); } template static eq< succ, succ > suc( eq ) { return eq< succ, succ >(); } template static eq< add, Y > zero_plus() { return eq< add, Y >(); } template static eq< add,Y>, succ< add > > succ_plus() { return eq< add,Y>, succ< add > >(); } }; template struct replace { typedef T type; }; template struct replace { typedef V type; }; template class Bin, typename T1, typename T2, typename X, typename V> struct replace,X,V> { typedef Bin::type, typename replace::type> type; }; template struct fresh { typedef fresh type; }; template class forall { private: forall() {} typedef typename fresh::type N; public: forall( typename replace< PROP, X, zero >::type, typename replace< PROP, X, succ >::type (*)( typename replace::type ) ) {} }; eq< add, add > case_zero() { return axiom::reflexive< add >(); } template eq< add,zero>, add > > case_step( eq< add, add > indhyp ) { eq< add , N > p1 = axiom::zero_plus(); eq< add , N > p2 = axiom::transitive( indhyp, p1 ); eq< succ< add > , succ > p3 = axiom::suc( p2 ); eq< add,zero> , succ< add > > p4 = axiom::succ_plus(); eq< add,zero> , succ > p5 = axiom::transitive( p4, p3 ); eq< add< zero,succ > , succ > p6 = axiom::zero_plus< succ >(); eq< succ , add< zero,succ > > p7 = axiom::symmetric( p6 ); eq< add,zero> , add< zero,succ > > p8 = axiom::transitive( p5, p7 ); return p8; } class X {}; int main() { // 1+1 = 2 { eq< add< succ, succ >, succ< add< zero, succ > > > p1 = axiom::succ_plus< zero, succ >(); eq< add< zero, succ >, succ > p2 = axiom::zero_plus< succ >(); eq< succ< add< zero, succ > >, succ< succ > > p3 = axiom::suc( p2 ); eq< add< succ, succ >, succ< succ > > proof_of_1_plus_1_is_2 = axiom::transitive( p1, p3 ); } // forall X. X+0=0+X { forall< X, eq< add, add > > proof( case_zero(), &case_step ); } }