fn subgoal(
        &mut self,
        goal_depth: StackIndex,
        goal: InEnvironment<Goal>,
        subst: Substitution,
        minimums: &mut Minimums,
    ) -> ExplorationResult {
        debug_heading!(
            "subgoal(goal_depth={:?}, goal={:?}, minimums={:?})",
            goal_depth,
            goal,
            minimums
        );

        // We want to consider two cases:
        //
        // - The goal is a domain goal. In that case, we will make N alternatives,
        //   one for each clause we can find.
        // - The goal is some other kind of HH goal. In that case, we will break it
        //   down into a product of literals, and create 1 alternative.

        let InEnvironment { environment, goal } = goal;
        match goal {
            Goal::Leaf(LeafGoal::DomainGoal(domain_goal)) => {
                let domain_goal = InEnvironment::new(&environment, domain_goal);
                let clauses = self.clauses(&domain_goal);

                for clause in clauses {
                    self.snapshotted(|this| {
                        match resolvent::resolvent_clause(
                            &mut this.infer,
                            &domain_goal,
                            &subst,
                            &clause.implication,
                        ) {
                            Satisfiable::No => Ok(FullyExplored),
                            Satisfiable::Yes(resolvent) => {
                                this.new_clause(goal_depth, resolvent, minimums)
                            }
                        }
                    })?;
                }
            }

            _ => {
                // `canonical_goal` is an HH goal. We can simplify it
                // into a series of *literals*, all of which must be
                // true. Thus, in EWFS terms, we are effectively
                // creating a single child of the `A :- A` goal that
                // is like `A :- B, C, D` where B, C, and D are the
                // simplified subgoals. You can think of this as
                // applying built-in "meta program clauses" that
                // reduce HH goals into Domain goals.
                let hh_goal = InEnvironment::new(&environment, goal);
                let ex_clause = match Self::simplify_hh_goal(&mut self.infer, subst, hh_goal) {
                    Satisfiable::Yes(ex_clause) => ex_clause,
                    Satisfiable::No => return Ok(FullyExplored), // now way to solve
                };

                self.new_clause(goal_depth, ex_clause, minimums)?;
            }
        }

        debug!(
            "subgoal: goal_depth={:?} minimums={:?}",
            goal_depth,
            minimums
        );
        self.complete(goal_depth, minimums)
    }
/// This is SLG_SUBGOAL from EWFS. It is invoked when a new goal
/// has been freshly pushed. We do a slight tweak to account for
/// HH vs domain goals.
This is SLG_SUBGOAL from EWFS. It is invoked when a new goal
has been freshly pushed. We do a slight tweak to account for
HH vs domain goals.
This is SLG_SUBGOAL from EWFS . It is invoked when a new goal has been freshly pushed . We do a slight tweak to account for HH vs domain goals .
fn subgoal(
        &mut self,
        goal_depth: StackIndex,
        goal: InEnvironment<Goal>,
        subst: Substitution,
        minimums: &mut Minimums,
    ) -> ExplorationResult {
        debug_heading!(
            "subgoal(goal_depth={:?}, goal={:?}, minimums={:?})",
            goal_depth,
            goal,
            minimums
        );
        // We want to consider two cases:
        //
        // - The goal is a domain goal. In that case, we will make N alternatives,
        //   one for each clause we can find.
        // - The goal is some other kind of HH goal. In that case, we will break it
        //   down into a product of literals, and create 1 alternative.
        let InEnvironment { environment, goal } = goal;
        match goal {
            Goal::Leaf(LeafGoal::DomainGoal(domain_goal)) => {
                let domain_goal = InEnvironment::new(&environment, domain_goal);
                let clauses = self.clauses(&domain_goal);
                for clause in clauses {
                    self.snapshotted(|this| {
                        match resolvent::resolvent_clause(
                            &mut this.infer,
                            &domain_goal,
                            &subst,
                            &clause.implication,
                        ) {
                            Satisfiable::No => Ok(FullyExplored),
                            Satisfiable::Yes(resolvent) => {
                                this.new_clause(goal_depth, resolvent, minimums)
                            }
                        }
                    })?;
                }
            }
            _ => {
                // `canonical_goal` is an HH goal. We can simplify it
                // into a series of *literals*, all of which must be
                // true. Thus, in EWFS terms, we are effectively
                // creating a single child of the `A :- A` goal that
                // is like `A :- B, C, D` where B, C, and D are the
                // simplified subgoals. You can think of this as
                // applying built-in "meta program clauses" that
                // reduce HH goals into Domain goals.
                let hh_goal = InEnvironment::new(&environment, goal);
                let ex_clause = match Self::simplify_hh_goal(&mut self.infer, subst, hh_goal) {
                    Satisfiable::Yes(ex_clause) => ex_clause,
                    Satisfiable::No => return Ok(FullyExplored), // now way to solve
                };
                self.new_clause(goal_depth, ex_clause, minimums)?;
            }
        }
        debug!(
            "subgoal: goal_depth={:?} minimums={:?}",
            goal_depth,
            minimums
        );
        self.complete(goal_depth, minimums)
    }
fn subgoal ( & mut self , goal_depth : StackIndex , goal : InEnvironment < Goal > , subst : Substitution , minimums : & mut Minimums , ) -> ExplorationResult { debug_heading ! ( " " goal_depth goal minimums ) ; // We want to consider two cases: // // - The goal is a domain goal. In that case, we will make N alternatives, //   one for each clause we can find. // - The goal is some other kind of HH goal. In that case, we will break it //   down into a product of literals, and create 1 alternative. let InEnvironment { environment , goal } = goal ; match goal { Goal :: Leaf ( LeafGoal :: DomainGoal ( domain_goal ) ) => { let domain_goal = InEnvironment :: new ( & environment , domain_goal ) ; let clauses = self . clauses ( & domain_goal ) ; for clause in clauses { self . snapshotted ( | this | { match resolvent :: resolvent_clause ( & mut this . infer , & domain_goal , & subst , & clause . implication , ) { Satisfiable :: No => Ok ( FullyExplored ) , Satisfiable :: Yes ( resolvent ) => { this . new_clause ( goal_depth , resolvent , minimums ) } } } ) ? ; } } _ => { // `canonical_goal` is an HH goal. We can simplify it // into a series of *literals*, all of which must be // true. Thus, in EWFS terms, we are effectively // creating a single child of the `A :- A` goal that // is like `A :- B, C, D` where B, C, and D are the // simplified subgoals. You can think of this as // applying built-in "meta program clauses" that // reduce HH goals into Domain goals. let hh_goal = InEnvironment :: new ( & environment , goal ) ; let ex_clause = match Self :: simplify_hh_goal ( & mut self . infer , subst , hh_goal ) { Satisfiable :: Yes ( ex_clause ) => ex_clause , Satisfiable :: No => return Ok ( FullyExplored ) , // now way to solve } ; self . new_clause ( goal_depth , ex_clause , minimums ) ? ; } } debug ! ( " " goal_depth minimums ) ; self . complete ( goal_depth , minimums ) }
This is SLG_SUBGOAL from EWFS.
This is SLG_SUBGOAL from EWFS .
&mut self
goal_depth
StackIndex
goal
InEnvironment<Goal>
subst
Substitution
minimums
&mut Minimums