Class: RDF::N3::Algebra::Log::Implies
 Inherits:

SPARQL::Algebra::Operator::Binary
 Object
 SPARQL::Algebra::Operator
 SPARQL::Algebra::Operator::Binary
 RDF::N3::Algebra::Log::Implies
 Defined in:
 vendor/bundler/ruby/2.6.0/bundler/gems/rdfn3015ce184efe3/lib/rdf/n3/algebra/log/implies.rb
Overview
Logical implication.
This is the relation between the antecedent (subject) and conclusion (object) of a rule. The application of a rule to a knowledgebase is as follows. For every substitution which, applied to the antecedent, gives a formula which is a subset of the knowledgebase, then the result of applying that same substitution to the conclusion may be added to the knowledgebase.
related: See log:conclusion.
Constant Summary collapse
 NAME =
:logImplies
Constants included from Util::Logger
Constants inherited from SPARQL::Algebra::Operator::Binary
SPARQL::Algebra::Operator::Binary::ARITY
Constants inherited from SPARQL::Algebra::Operator
SPARQL::Algebra::Operator::ARITY, SPARQL::Algebra::Operator::IsURI, SPARQL::Algebra::Operator::URI
Instance Attribute Summary
Attributes included from Enumerable
Attributes included from SPARQL::Algebra::Query
Attributes inherited from SPARQL::Algebra::Operator
Instance Method Summary collapse

#each {statement ... } ⇒ Object
Yields statements from the object based on solutions determined from the subject.

#execute(queryable, solutions:, **options) ⇒ RDF::Solutions
Yields solutions from subject.

#graph_name ⇒ RDF::Resource
Graph name associated with this operation, using the name of the parent.
Methods included from Util::Logger
#log_debug, #log_depth, #log_error, #log_fatal, #log_info, #log_recover, #log_recovering?, #log_statistics, #log_warn, #logger
Methods included from Enumerable
add_entailment, #contain?, #dump, #each_graph, #each_object, #each_predicate, #each_quad, #each_statement, #each_subject, #each_term, #each_triple, #entail, #enum_graph, #enum_object, #enum_predicate, #enum_quad, #enum_statement, #enum_subject, #enum_term, #enum_triple, #graph_names, #has_graph?, #has_object?, #has_predicate?, #has_quad?, #has_statement?, #has_subject?, #has_term?, #has_triple?, #invalid?, #method_missing, #objects, #predicates, #project_graph, #quads, #respond_to_missing?, #statements, #subjects, #supports?, #terms, #to_a, #to_h, #to_set, #triples, #valid?, #validate!
Methods included from Util::Aliasing::LateBound
Methods included from Countable
Methods included from Isomorphic
#bijection_to, #isomorphic_with?
Methods included from SPARQL::Algebra::Update
#graph_name=, #unshift, #variables
Methods included from SPARQL::Algebra::Query
#each_solution, #empty?, #failed?, #graph_name=, #matched?, #query_yields_boolean?, #query_yields_solutions?, #query_yields_statements?, #unshift, #variables
Methods inherited from SPARQL::Algebra::Operator::Binary
Methods inherited from SPARQL::Algebra::Operator
#aggregate?, arity, #base_uri, base_uri, base_uri=, #boolean, #constant?, #each_descendant, #eql?, #evaluatable?, evaluate, #executable?, #first_ancestor, for, #initialize, #inspect, #ndvars, #node?, #operand, #optimize, #parent, #parent=, prefixes, #prefixes, prefixes=, #rewrite, #to_binary, #to_sxp, #to_sxp_bin, #validate!, #variable?, #vars
Methods included from SPARQL::Algebra::Expression
cast, #constant?, #evaluate, extension, extensions, for, #invalid?, new, #node?, open, #optimize, parse, register_extension, #to_sxp_bin, #valid?, #validate!, #variable?
Constructor Details
This class inherits a constructor from SPARQL::Algebra::Operator::Binary
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RDF::Enumerable
Instance Method Details
#each {statement ... } ⇒ Object
Yields statements from the object based on solutions determined from the subject. Each solution formed by querying queryable
from the subject is used to create a graph, which must be a subgraph of queryable
. If so, that solution is used to generate triples from the object formula which are yielded.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/rdfn3015ce184efe3/lib/rdf/n3/algebra/log/implies.rb', line 42 def each(&block) @solutions = RDF::Query::Solutions.new log_debug {"logImplies each #{@solutions.to_sxp}"} subject, object = operands if @solutions.empty? # Some evalaluatable operand evaluated to false log_debug("(logImplies implication false  no solutions)") return end # Graph based on solutions from subject subject_graph = log_depth {RDF::Graph.new {g g << subject}} # Use solutions from subject for object object.solutions = @solutions # Nothing emitted if @solutions is not complete. Solutions are complete when all variables are bound. if @queryable.contain?(subject_graph) log_debug("(logImplies implication true)") # Yield statements into the default graph log_depth do object.each do statement block.call(RDF::Statement.from(statement.to_triple, inferred: true, graph_name: graph_name)) end end else log_debug("(logImplies implication false)") end end 
#execute(queryable, solutions:, **options) ⇒ RDF::Solutions
Yields solutions from subject. Solutions are created by evaluating subject against queryable
.
25 26 27 28 29 30 31 32 33 
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/rdfn3015ce184efe3/lib/rdf/n3/algebra/log/implies.rb', line 25 def execute(queryable, solutions:, **) @queryable = queryable log_debug {"logImplies"} @solutions = log_depth {operands.first.execute(queryable, solutions: solutions, **)} log_debug {"(logImplies solutions) #{@solutions.to_sxp}"} # Return original solutions, without bindings solutions end 
#graph_name ⇒ RDF::Resource
Graph name associated with this operation, using the name of the parent
75 
# File 'vendor/bundler/ruby/2.6.0/bundler/gems/rdfn3015ce184efe3/lib/rdf/n3/algebra/log/implies.rb', line 75 def graph_name; parent.graph_name; end 