fn resolvent_clause(
        &mut self,
        environment: &Arc<Environment>,
        goal: &DomainGoal,
        subst: &Substitution,
        clause: &ProgramClause,
    ) -> Fallible<Canonical<ExClause<SlgContext>>> {
        // Relating the above description to our situation:
        //
        // - `goal` G, except with binders for any existential variables.
        //   - Also, we always select the first literal in `ex_clause.literals`, so `i` is 0.
        // - `clause` is C, except with binders for any existential variables.

        debug_heading!(
            "resolvent_clause(\
             \n    goal={:?},\
             \n    clause={:?})",
            goal,
            clause,
        );

        let snapshot = self.infer.snapshot();

        // C' in the description above is `consequence :- conditions`.
        //
        // Note that G and C' have no variables in common.
        let ProgramClauseImplication {
            consequence,
            conditions,
        } = match clause {
            ProgramClause::Implies(implication) => implication.clone(),
            ProgramClause::ForAll(implication) => {
                self.infer.instantiate_binders_existentially(implication)
            }
        };
        debug!("consequence = {:?}", consequence);
        debug!("conditions = {:?}", conditions);

        // Unify the selected literal Li with C'.
        let unification_result = self.infer.unify(environment, goal, &consequence)?;

        // Final X-clause that we will return.
        let mut ex_clause = ExClause {
            subst: subst.clone(),
            delayed_literals: vec![],
            constraints: vec![],
            subgoals: vec![],
        };

        // Add the subgoals/region-constraints that unification gave us.
        implementation::into_ex_clause(unification_result, &mut ex_clause);

        // Add the `conditions` from the program clause into the result too.
        ex_clause
            .subgoals
            .extend(conditions.into_iter().map(|c| match c {
                Goal::Not(c) => Literal::Negative(InEnvironment::new(environment, *c)),
                c => Literal::Positive(InEnvironment::new(environment, c)),
            }));

        let canonical_ex_clause = self.infer.canonicalize(&ex_clause).quantified;

        self.infer.rollback_to(snapshot);

        Ok(canonical_ex_clause)
    }
/// Applies the SLG resolvent algorithm to incorporate a program
/// clause into the main X-clause, producing a new X-clause that
/// must be solved.
///
/// # Parameters
///
/// - `goal` is the goal G that we are trying to solve
/// - `clause` is the program clause that may be useful to that end
Applies the SLG resolvent algorithm to incorporate a program
clause into the main X-clause, producing a new X-clause that
must be solved.
Applies the SLG resolvent algorithm to incorporate a program clause into the main X - clause producing a new X - clause that must be solved .
fn resolvent_clause(
        &mut self,
        environment: &Arc<Environment>,
        goal: &DomainGoal,
        subst: &Substitution,
        clause: &ProgramClause,
    ) -> Fallible<Canonical<ExClause<SlgContext>>> {
        // Relating the above description to our situation:
        //
        // - `goal` G, except with binders for any existential variables.
        //   - Also, we always select the first literal in `ex_clause.literals`, so `i` is 0.
        // - `clause` is C, except with binders for any existential variables.
        debug_heading!(
            "resolvent_clause(\
             \n    goal={:?},\
             \n    clause={:?})",
            goal,
            clause,
        );
        let snapshot = self.infer.snapshot();
        // C' in the description above is `consequence :- conditions`.
        //
        // Note that G and C' have no variables in common.
        let ProgramClauseImplication {
            consequence,
            conditions,
        } = match clause {
            ProgramClause::Implies(implication) => implication.clone(),
            ProgramClause::ForAll(implication) => {
                self.infer.instantiate_binders_existentially(implication)
            }
        };
        debug!("consequence = {:?}", consequence);
        debug!("conditions = {:?}", conditions);
        // Unify the selected literal Li with C'.
        let unification_result = self.infer.unify(environment, goal, &consequence)?;
        // Final X-clause that we will return.
        let mut ex_clause = ExClause {
            subst: subst.clone(),
            delayed_literals: vec![],
            constraints: vec![],
            subgoals: vec![],
        };
        // Add the subgoals/region-constraints that unification gave us.
        implementation::into_ex_clause(unification_result, &mut ex_clause);
        // Add the `conditions` from the program clause into the result too.
        ex_clause
            .subgoals
            .extend(conditions.into_iter().map(|c| match c {
                Goal::Not(c) => Literal::Negative(InEnvironment::new(environment, *c)),
                c => Literal::Positive(InEnvironment::new(environment, c)),
            }));
        let canonical_ex_clause = self.infer.canonicalize(&ex_clause).quantified;
        self.infer.rollback_to(snapshot);
        Ok(canonical_ex_clause)
    }
fn resolvent_clause ( & mut self , environment : & Arc < Environment > , goal : & DomainGoal , subst : & Substitution , clause : & ProgramClause , ) -> Fallible < Canonical < ExClause < SlgContext > > > { // Relating the above description to our situation: // // - `goal` G, except with binders for any existential variables. //   - Also, we always select the first literal in `ex_clause.literals`, so `i` is 0. // - `clause` is C, except with binders for any existential variables. debug_heading ! ( " \
 \n \
 \n " goal clause ) ; let snapshot = self . infer . snapshot ( ) ; // C' in the description above is `consequence :- conditions`. // // Note that G and C' have no variables in common. let ProgramClauseImplication { consequence , conditions , } = match clause { ProgramClause :: Implies ( implication ) => implication . clone ( ) , ProgramClause :: ForAll ( implication ) => { self . infer . instantiate_binders_existentially ( implication ) } } ; debug ! ( " " consequence ) ; debug ! ( " " conditions ) ; // Unify the selected literal Li with C'. let unification_result = self . infer . unify ( environment , goal , & consequence ) ? ; // Final X-clause that we will return. let mut ex_clause = ExClause { subst : subst . clone ( ) , delayed_literals : vec ! [ ] , constraints : vec ! [ ] , subgoals : vec ! [ ] , } ; // Add the subgoals/region-constraints that unification gave us. implementation :: into_ex_clause ( unification_result , & mut ex_clause ) ; // Add the `conditions` from the program clause into the result too. ex_clause . subgoals . extend ( conditions . into_iter ( ) . map ( | c | match c { Goal :: Not ( c ) => Literal :: Negative ( InEnvironment :: new ( environment , * c ) ) , c => Literal :: Positive ( InEnvironment :: new ( environment , c ) ) , } ) ) ; let canonical_ex_clause = self . infer . canonicalize ( & ex_clause ) . quantified ; self . infer . rollback_to ( snapshot ) ; Ok ( canonical_ex_clause ) }
Applies the SLG resolvent algorithm to incorporate a program
clause into the main X-clause, producing a new X-clause that
must be solved.
Applies the SLG resolvent algorithm to incorporate a program clause into the main X - clause producing a new X - clause that must be solved .
&mut self
environment
&Arc<Environment>
goal
&DomainGoal
subst
&Substitution
clause
&ProgramClause
&mut self
environment
&Arc<Environment>
goal
&DomainGoal
None
subst
&Substitution
clause
&ProgramClause
None