diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
@@ -42,9 +42,8 @@ vector<Axiom> importAxioms(const vector<string> &list){ using Heuristic = int (*)(const Tree&); -int heuristic(const Tree &tree){ - return tree.nleaves(); -} +int heuristic_nleaves(const Tree &tree){return tree.nleaves();} +int heuristic_height(const Tree &tree){return tree.height();} template <Heuristic F> struct AscendingCompare{ @@ -99,25 +98,43 @@ vector<Tree>* deduceEq(const vector<Axiom> &axioms,const Tree &startTree,const T } +void test_func(){ + Tree from("([2]*([2]*1))"),to("10"); + Tree subj("(([1]*1)*[1])"); + + /*unordered_set<Variable> temps=to.collectTemporaries(); + for(Variable v : temps){ + cout<<v<<endl; + }*/ + + vector<Tree> res=subj.replace(from,to); + for(const Tree &t : res){ + cout<<t<<endl; + } +} + int main(){ + test_func(); + return 0; + const vector<Axiom> axioms=importAxioms({ - // "([1]*[2])>([2]*[1])", - // "(([1]*[2])*[3])=([1]*([2]*[3]))", + // "([1]*[2])>([2]*[1])", // Commutativity + // "(([1]*[2])*[3])=([1]*([2]*[3]))", // Associativity - // "([1]*([1]*[2]))=[1]", - // "(([2]*[1])*[1])=[1]", + "([1]*([1]*[2]))=[1]", // Onno's 1=2 axioms + "(([2]*[1])*[1])=[1]", // "[1]=([1]*[1])", // "(([1]*[2])*[3])=(([2]*[3])*[1])", - "[1]=[2]", + // "[1]=[2]", }); - const Tree t_from("(1*2)"),t_to("(2*1)"); + const Tree t_from("1"),t_to("2"); for(const Axiom &ax : axioms)cout<<ax<<endl; cout<<endl; - vector<Tree> *res=deduceEq<heuristic>(axioms,t_from,t_to); + vector<Tree> *res=deduceEq<heuristic_nleaves>(axioms,t_from,t_to); if(res==nullptr){ cout<<"No deduction"<<endl; } else { |