------------------------------------------------------------------------------ Expression: "a" Tree: -[a ] Labelled graph: [(0,"a",[])] Simplified tree: -[0:a ] ------------------------------------------------------------------------------ Expression: ("+" "a" "a") Tree: -[+ ]-+-[a ] | `-[a ] Labelled graph: [(0,"+",[2,2]), (2,"a",[])] Simplified tree: -[0:+ ]-+-[2:a ] | `-[2:<>] ------------------------------------------------------------------------------ Expression: ("+" ("*" "a" "b") ("*" "a" "b")) Tree: -[+ ]-+-[* ]-+-[a ] | | | `-[b ] | `-[* ]-+-[a ] | `-[b ] Labelled graph: [(0,"+",[4,4]), (4,"*",[5,6]), (5,"a",[]), (6,"b",[])] Simplified tree: -[0:+ ]-+-[4:* ]-+-[5:a ] | | | `-[6:b ] | `-[4:<>] ------------------------------------------------------------------------------ Expression: ("+" ("*" ("+" "a" "b") "c") ("+" "a" "b")) Tree: -[+ ]-+-[* ]-+-[+ ]-+-[a ] | | | | | `-[b ] | | | `-[c ] | `-[+ ]-+-[a ] | `-[b ] Labelled graph: [(0,"+",[1,6]), (1,"*",[6,5]), (5,"c",[]), (6,"+",[7,8]), (7,"a",[]), (8,"b",[])] Simplified tree: -[0:+ ]-+-[1:* ]-+-[6:+ ]-+-[7:a ] | | | | | `-[8:b ] | | | `-[5:c ] | `-[6:<>] ------------------------------------------------------------------------------ Expression: ("X" "0" ("+" "0" "a") ("+" ("+" "0" "a") "b") ("+" ("+" ("+" "0" "a") "b") "c") ("+" ("+" ("+" ("+" "0" "a") "b") "c") "d")) Tree: -[X ]-+-[0 ] | +-[+ ]-+-[0 ] | | | `-[a ] | +-[+ ]-+-[+ ]-+-[0 ] | | | | | `-[a ] | | | `-[b ] | +-[+ ]-+-[+ ]-+-[+ ]-+-[0 ] | | | | | | | `-[a ] | | | | | `-[b ] | | | `-[c ] | `-[+ ]-+-[+ ]-+-[+ ]-+-[+ ]-+-[0 ] | | | | | | | `-[a ] | | | | | `-[b ] | | | `-[c ] | `-[d ] Labelled graph: [(0,"X",[21,20,19,18,17]), (17,"+",[18,25]), (18,"+",[19,24]), (19,"+",[20,23]), (20,"+",[21,22]), (21,"0",[]), (22,"a",[]), (23,"b",[]), (24,"c",[]), (25,"d",[])] Simplified tree: -[0:X ]-+-[21:0] | +-[20:+]-+-[21:<] | | | `-[22:a] | +-[19:+]-+-[20:<] | | | `-[23:b] | +-[18:+]-+-[19:<] | | | `-[24:c] | `-[17:+]-+-[18:<] | `-[25:d] ------------------------------------------------------------------------------ Expression: ("X" ("+" "a" ("+" "b" ("+" "c" ("+" "d" "0")))) ("+" "b" ("+" "c" ("+" "d" "0"))) ("+" "c" ("+" "d" "0")) ("+" "d" "0") "0") Tree: -[X ]-+-[+ ]-+-[a ] | | | `-[+ ]-+-[b ] | | | `-[+ ]-+-[c ] | | | `-[+ ]-+-[d ] | | | `-[0 ] | +-[+ ]-+-[b ] | | | `-[+ ]-+-[c ] | | | `-[+ ]-+-[d ] | | | `-[0 ] | +-[+ ]-+-[c ] | | | `-[+ ]-+-[d ] | | | `-[0 ] | +-[+ ]-+-[d ] | | | `-[0 ] | `-[0 ] Labelled graph: [(0,"X",[1,10,17,22,25]), (1,"+",[2,10]), (2,"a",[]), (10,"+",[11,17]), (11,"b",[]), (17,"+",[18,22]), (18,"c",[]), (22,"+",[23,25]), (23,"d",[]), (25,"0",[])] Simplified tree: -[0:X ]-+-[1:+ ]-+-[2:a ] | | | `-[10:+]-+-[11:b] | | | `-[17:+]-+-[18:c] | | | `-[22:+]-+-[23:d] | | | `-[25:0] | +-[10:<] | +-[17:<] | +-[22:<] | `-[25:<]