Representing Logical Combinations in Analysis Programs

  • Thread starter Thread starter DEvens
  • Start date Start date
  • Tags Tags
    String
Click For Summary

Discussion Overview

The discussion revolves around the representation of logical combinations in analysis programs, specifically focusing on how to internally represent strings of combinations of logical operations (AND, OR, NOT) in a structured format. The context includes technical considerations related to programming and data structures.

Discussion Character

  • Technical explanation, Debate/contested

Main Points Raised

  • One participant describes a specific input format for an analysis program (MCNP) that uses a combination of logical operations represented in a string format.
  • Another participant suggests using symbols like + for OR, * for AND, and ~ for NOT for string representation, and proposes a node structure with four types of nodes (value, AND, OR, NOT) for internal representation.
  • A participant references an external source (Wikipedia) discussing AND-OR trees, noting differences in node structures between the source and their own proposal, particularly regarding the number of children nodes.
  • There is a discussion about the efficiency and implementation complexity of using different node structures based on programming language and algorithm requirements.
  • Participants engage in clarifying and correcting their previous statements regarding the examples provided, indicating some confusion over the representation of logical combinations.
  • One participant expresses a desire to close the thread after a perceived resolution of their question.

Areas of Agreement / Disagreement

Participants have differing views on the optimal internal representation of logical combinations, with no consensus reached on a single standard approach. There is also some confusion and correction regarding the examples given, indicating a lack of clarity in the discussion.

Contextual Notes

The discussion includes limitations related to the assumptions about node structures and the complexity of implementation in different programming contexts. There are unresolved aspects regarding the efficiency of various representations.

DEvens
Homework Helper
Education Advisor
Gold Member
Messages
1,246
Reaction score
508
TL;DR
How to internally represent string of and's and or's
I have an analysis program. (It's MCNP if it makes any difference.) Part of the input is to specify the surfaces of a cell in a string of "this side of surface x" and "that side of surface y" entries. It looks a little something like this.

((a b):(c -d)):(f -g))

So the : means "or" and otherwise it's "and". So this example is

{(outside a and outside b ) or (outside c and inside d) } or (outside f and inside g)

So my question is, is there a standard way of internally representing such strings of combinations of and's and or's? I'm thinking possibly some kind of tree structure? This seems like it should be one of those "standard questions" that gets asked all the time.
 
Last edited:
Technology news on Phys.org
For string representation I'd use somethijg like + for or, * for and and ~ for not.

But internally as you suggest some kind of node structure that suits the language you are using would be best - four kinds of node (value, and, or and not) with pointers to child nodes.
 
DEvens said:
So this example is
{(outside a and outside b ) or (outside c and inside d) }
I would read (outside c or inside d)
 
DEvens said:
Well that's a slightly different arrangement to the one I outlined (and you hinted at); the nodes on the wiki page have an arbitrary number of children whereas 'my' nodes have at most two children. Depending on the particular circumstances (language, data, algorithm), one of these may be more efficient and/or easier to implement than the other. In particular dealing with an arbitrary number of things in a low-level language is more complicated than dealing with at most two.

BvU said:
I would read (outside c or inside d)
Yes, IME it is always better to stick to + * and ~ or some similar characters in the base 7 bit ASCII set where you are dealing with operations that are similar to addition, multiplication and negation.
 
BvU said:
I would read (outside c or inside d)

Fixed.
 
pbuk said:
Well that's a slightly different arrangement to the one I outlined (and you hinted at); the nodes on the wiki page have an arbitrary number of children whereas 'my' nodes have at most two children.
[snips]

Considering that my example already had three...
 
DEvens said:
Considering that my example already had three...

This has three:
Code:
(a b):(c -d):(f -g)

but you wrote

DEvens said:
Code:
((a b):(c -d)):(f -g)
 
DEvens said:
Fixed.
Great. Now my post looks like nonsense :wink:
 
  • #10
Guys, maybe you noticed the post where I said "Got it!" and posted a link? Mods, please close this thread.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
1
Views
2K