!7 srecord ProposeRewrite(S a, S b) {} p-exp { new ThoughtSpace1 ts; ts.setInput("let's have a cup of Joe"); ts.add(Definition("let's have", "a grouping prefix")); ts.addStepper(voidfunc(ThoughtSpace1 ts) { S s = ts.getInput(); if (empty(s)) ret; for (S prefix : sentencePrefixes_notEmpty_rev(s)) if (cic(ts.getDefinitionTexts(prefix), "a grouping prefix")) ts.add(ProposeRewrite(s, prefix + " " + curlyBrace(trim(dropPrefix(prefix, s))))); }); ts.printStats = true; ts.think(true); }