Module: Predicate::And

Includes:
NadicBool
Defined in:
lib/predicate/nodes/and.rb

Constant Summary

Constants included from Expr

Expr::OP_NEGATIONS

Instance Method Summary collapse

Methods included from NadicBool

#free_variables, #priority

Methods included from Expr

#!, #&, #contradiction?, #qualify, #rename, #sexpr, #tautology?, #to_proc, #to_ruby_code, #to_sequel, #|

Methods included from Factory

#and, #between, #comp, #contradiction, #from_hash, #identifier, #in, #literal, #native, #not, #or, #qualified_identifier, #tautology

Instance Method Details

#and_split(attr_list) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/predicate/nodes/and.rb', line 9

def and_split(attr_list)
  # Say we are X = X1 & X2 & X3
  # We will split each term: X = (X1 & Y1) & (X2 & Y2) & (X3 & Y3)
  # ... such that Y1, Y2, and Y2 makes no reference to attr_list
  # ... which is equivalent to (X1 & X2 & X3) & (Y1 & Y2 & Y3)
  # ... hence P1 & P2, that we return
  sexpr_body.inject([tautology, tautology]) do |(top,down),term|
    p1, p2 = term.and_split(attr_list)
    [top & p1, down & p2]
  end
end

#constant_variablesObject



21
22
23
24
25
# File 'lib/predicate/nodes/and.rb', line 21

def constant_variables
  sexpr_body.inject([]) do |cvars,expr|
    cvars | expr.constant_variables
  end
end

#operator_symbolObject



5
6
7
# File 'lib/predicate/nodes/and.rb', line 5

def operator_symbol
  :'&&'
end