dyval.DAG.logic_dag

class promptbench.dyval.DAG.logic_dag.AbductionDAG(ops, uni_ops, depth, probs=[0.16, 0.51, 0.33], num_children_per_node=2)

Bases: TreeDAG

A specialized TreeDAG for abductive reasoning.

Parameters:

-----------

opslist

List of operations for abduction (e.g., ‘and’, ‘or’, ‘not’).

uni_opslist

List of unary operations.

depthint

Depth of the tree.

probslist of float, optional

Probability distribution for selecting operations.

num_children_per_nodeint, optional

Number of children per node.

Methods:

generate_tree(depth)

Generates an abductive reasoning tree.

_find_path(start, end)

Finds a path from start node to end node.

abduct_node_value(start, end)

Performs abductive reasoning from start to end node.

check_link_constraint(father_node, child_node)

Checks if a link between two nodes is valid (always False for AbductionDAG).

update_values()

Updates the values of the nodes based on abductive logic (always returns True).

abduct_node_value(start, end)

Adding links are not allowed in abduction DAGs

generate_tree(depth)
update_values()
class promptbench.dyval.DAG.logic_dag.AbductionDAGDescriber(dag_obj, ops, uni_ops, add_rand_desc=0)

Bases: TreeDAGDescriber

Describer class for AbductionDAG.

Provides methods to describe nodes and their abductive logic in AbductionDAG.

Parameters:

dag_objAbductionDAG

The AbductionDAG instance to describe.

opslist

List of operations.

uni_opslist

List of unary operations.

add_rand_descint, optional

Number of random descriptions to add.

Methods:

describe_question_node(node)

Describes an AbductionDAG node for question formation.

describe_abduction()

Describes the abduction process from a start node to an end node.

describe_inference_steps()

Describes the inference steps in the abduction process.

describe_answer()

Provides the answer based on the abduction process.

describe_question()

Describes the DAG for question formation in various traversal orders.

describe_abduction()
describe_answer()
describe_inference_steps()
describe_question()
describe_question_node(node)
class promptbench.dyval.DAG.logic_dag.BoolDAG(ops, uni_ops, depth, num_children_per_node=2, extra_links_per_node=1, add_cycles=0)

Bases: TreeDAG

A specialized TreeDAG for Boolean logic operations.

Extends TreeDAG to represent boolean logic trees where nodes represent boolean values and operations.

Parameters:

opslist

List of binary operations (e.g., ‘and’, ‘or’).

uni_opslist

List of unary operations (e.g., ‘not’).

depthint

Depth of the tree.

num_children_per_nodeint, optional

Number of children per node (default is 2).

extra_links_per_nodeint, optional

Extra links per node (default is 1).

add_cyclesint, optional

Number of cycles to add to the tree (default is 0).

Methods:

generate_tree(depth)

Generates the tree structure with specified depth.

check_link_constraint(father_node, child_node)

Checks if a link between two nodes is valid.

update_values()

Updates the values of the nodes based on their boolean logic.

generate_tree(depth)
update_values()
class promptbench.dyval.DAG.logic_dag.BoolDAGDescriber(dag_obj, ops, uni_ops, add_rand_desc=0, delete_desc=0)

Bases: TreeDAGDescriber

Describer class for BoolDAG.

Provides methods to describe BoolDAG nodes and their boolean operations.

Parameters:

dag_objBoolDAG

The BoolDAG instance to describe.

opslist

List of binary operations.

uni_opslist

List of unary operations.

add_rand_descint, optional

Number of random descriptions to add.

delete_descint, optional

Number of descriptions to delete.

Methods:

describe_question_node(node)

Describes a BoolDAG node to form a question.

describe_inference_node(node)

Describes a BoolDAG node for inference steps (training).

describe_inference_node(node)
describe_question_node(node)
class promptbench.dyval.DAG.logic_dag.DeductionDAG(ops, uni_ops, depth, probs=[0.16, 0.51, 0.33], num_children_per_node=2)

Bases: TreeDAG

A specialized TreeDAG for deductive reasoning.

Parameters:

opslist

List of operations for deduction (e.g., ‘and’, ‘or’, ‘not’).

uni_opslist

List of unary operations.

depthint

Depth of the tree.

probslist of float, optional

Probability distribution for selecting operations (default is [0.16, 0.51, 0.33]).

num_children_per_nodeint, optional

Number of children per node.

Methods:

generate_tree(depth)

Generates a deductive reasoning tree.

check_link_constraint(father_node, child_node)

Checks if a link between two nodes is valid (always False for DeductionDAG).

update_values()

Updates the values of the nodes based on deductive logic (always returns True).

Adding links are not allowed in deduction DAGs

generate_tree(depth)
update_values()
class promptbench.dyval.DAG.logic_dag.DeductionDAGDescriber(dag_obj, ops, uni_ops, add_rand_desc=0)

Bases: TreeDAGDescriber

Describer class for DeductionDAG.

Provides methods to describe nodes and their deductive logic in DeductionDAG.

Parameters:

dag_objDeductionDAG

The DeductionDAG instance to describe.

opslist

List of operations.

uni_opslist

List of unary operations.

add_rand_descint, optional

Number of random descriptions to add.

Methods:

describe_question_node(node)

Describes a DeductionDAG node for question formation.

describe_inference_node(node)

Describes a DeductionDAG node for inference.

describe_inference_node(node)
describe_question_node(node)