Opened 9 years ago
Closed 8 years ago
#15018 closed enhancement (fixed)
add recover_formula and prefix_to_infix functions to logicparser.py
Reported by:  Paul Scurek  Owned by:  Paul Scurek 

Priority:  major  Milestone:  sage6.3 
Component:  misc  Keywords:  logic, logicparser, prefix, infix 
Cc:  Merged in:  
Authors:  Paul Scurek  Reviewers:  Frédéric Chapoton, Travis Scrimshaw 
Report Upstream:  N/A  Work issues:  
Branch:  521ba42 (Commits, GitHub, GitLab)  Commit:  521ba42dc81c1ebe1a13e0c9acff72cdcced6727 
Dependencies:  #14951, #14952, #15013  Stopgaps: 
Description
In the patch for this ticket, the functions recover_formula and prefix_to_infix are added to logicparser.py in the logic module. The function recover_formula allows for the recovery of a boolean formula from its parse tree. The function prefix_to_infix converts a parse tree from prefix form to infix form. Here are some examples.
sage: import sage.logic.logicparser as logicparser sage: t = ['>', ['~', 'a'], ['', 'c', ['~', 'd']]] sage: logicparser.recover_formula(t) '~a>(c~d)'
sage: import sage.logic.logicparser as logicparser sage: t = ['>', ['~', 'a'], ['', 'c', ['~', 'd']]] sage: logicparser.prefix_to_infix(t) [['~', 'a'], '>', ['c', '', ['~', 'd']]]
Attachments (5)
Change History (21)
comment:1 Changed 9 years ago by
Type:  PLEASE CHANGE → enhancement 

Changed 9 years ago by
Attachment:  trac_14951_tokenize_tree_fix.patch added 

comment:2 Changed 9 years ago by
Referee:
 trivial typo: "argrument" (in multiple places!)
 delete parens here: "prefix_to_infix() takes a parse tree as input"
 Someday somebody should change this...
type(tree[1]) is ListType
toisinstance(tree[1], list)
.
That's it.
Changed 9 years ago by
Attachment:  trac_15018_recover_formula.2.patch added 

Apply this last. This is the patch for this ticket, but depends on the previous 3.
Changed 9 years ago by
Attachment:  trac_15018_recover_formula.patch added 

This file is the same as trac_15018_recover_formula.2.patch.
comment:3 Changed 9 years ago by
I forgot to check the box for replacing the file with the same name. That is why there are attachments called trac_15018_recover_formula.patch and trac_15018_recover_formula.2.patch. They are exactly the same, so only apply one of them when testing the patch. I would get right of one of them, but I don't see an option for removing attachments.
comment:4 Changed 9 years ago by
Status:  new → needs_review 

comment:5 Changed 9 years ago by
The last patch listed in the attachments, trac_15018_recover_formula.patch, is the only patch that should be integrated into sage for this ticket. The first three patches are the patches from the dependencies for this ticket that were placed here for the convenience of the reviewer. The patch, trac_15018_recover_formula.2.patch is identical to trac_15018_recover_formula.patch.
comment:6 Changed 9 years ago by
Status:  needs_review → needs_work 

First patch of the series does not apply any more, please fix.
comment:7 Changed 9 years ago by
Branch:  → public/ticket/15018 

Commit:  → 86e7f6e0cb68c59a11fd05b7652f55b2b8378fdf 
Status:  needs_work → needs_review 
I've rebased this and made some minor doc changes. If everything is good, then positive review.
New commits:
9798dca  Trac 15018: added recover_formula, recover_formula_internal, prefix_to_infix, and to_infix_internal to logicparser.py

22ec476  Minor review tweaks.

bb23f1b  Merge branch 'develop' into public/ticket/15018

86e7f6e  Merge branch 'develop' into public/ticket/15018

comment:8 Changed 9 years ago by
Milestone:  sage6.1 → sage6.2 

comment:9 Changed 8 years ago by
Status:  needs_review → needs_work 

Work issues:  → needs rebase 
comment:10 Changed 8 years ago by
Milestone:  sage6.2 → sage6.3 

comment:11 Changed 8 years ago by
Commit:  86e7f6e0cb68c59a11fd05b7652f55b2b8378fdf → b4e8f25e140c688315d026add7318c65211e367c 

Branch pushed to git repo; I updated commit sha1. New commits:
b4e8f25  Merge branch 'public/ticket/15018' of trac.sagemath.org:sage into public/ticket/15018

comment:12 Changed 8 years ago by
Status:  needs_work → needs_review 

Work issues:  needs rebase 
comment:13 Changed 8 years ago by
Commit:  b4e8f25e140c688315d026add7318c65211e367c → 521ba42dc81c1ebe1a13e0c9acff72cdcced6727 

Branch pushed to git repo; I updated commit sha1. New commits:
521ba42  change raise syntax to python3 style

comment:14 Changed 8 years ago by
Reviewers:  → Frédéric Chapoton 

Status:  needs_review → positive_review 
looks good to me, positive review.
comment:15 Changed 8 years ago by
Reviewers:  Frédéric Chapoton → Frédéric Chapoton, Travis Scrimshaw 

Thanks Frederic.
comment:16 Changed 8 years ago by
Branch:  public/ticket/15018 → 521ba42dc81c1ebe1a13e0c9acff72cdcced6727 

Resolution:  → fixed 
Status:  positive_review → closed 
apply first