pub fn solve_and_reduce_with_accelerator<T: Clone + PartialEq + Eq + Hash, A>(
    start: &[T],
    goal: &[T],
    mut max_size: Option<usize>,
    filter: &[T],
    order_constraints: &[(T, T)],
    infer: fn(Solver<T, A>, story: &[T]) -> Option<T>,
    accelerator: fn(&[T], &[T]) -> A,
) -> (Vec<T>, Result<(), Error>) {
    let (mut res, status) = solve_with_accelerator(start, goal, max_size, filter,
        order_constraints, infer, &mut accelerator(start, goal));
    if status.is_err() {return (res, status)};

    // Check that every step is necessary.
    max_size = Some(res.len());
    let mut new_filter: Vec<T> = filter.into();
    loop {
        let old_len = res.len();
        for i in (0..res.len()).rev() {
            if goal.iter().any(|e| e == &res[i]) {continue;}

            new_filter.push(res[i].clone());

            if let (solution, Ok(())) = solve_with_accelerator(start, goal, max_size,
                &new_filter, order_constraints, infer, &mut accelerator(start, goal)) {
                if solution.len() < res.len() &&
                   solution.iter().all(|e| res.iter().any(|f| e == f))
                {
                    max_size = Some(solution.len());
                    res = solution;
                    break;
                }
            }

            new_filter.pop();
        }

        if res.len() == old_len {break;}
    }

    (res, Ok(()))
}
/// Solves and reduces the proof to those steps that are necessary.
///
/// Uses an accelerator constructor initalized from start and goal.
Solves and reduces the proof to those steps that are necessary.
Uses an accelerator constructor initalized from start and goal.
Solves and reduces the proof to those steps that are necessary . Uses an accelerator constructor initalized from start and goal .
pub fn solve_and_reduce_with_accelerator<T: Clone + PartialEq + Eq + Hash, A>(
    start: &[T],
    goal: &[T],
    mut max_size: Option<usize>,
    filter: &[T],
    order_constraints: &[(T, T)],
    infer: fn(Solver<T, A>, story: &[T]) -> Option<T>,
    accelerator: fn(&[T], &[T]) -> A,
) -> (Vec<T>, Result<(), Error>) {
    let (mut res, status) = solve_with_accelerator(start, goal, max_size, filter,
        order_constraints, infer, &mut accelerator(start, goal));
    if status.is_err() {return (res, status)};
    // Check that every step is necessary.
    max_size = Some(res.len());
    let mut new_filter: Vec<T> = filter.into();
    loop {
        let old_len = res.len();
        for i in (0..res.len()).rev() {
            if goal.iter().any(|e| e == &res[i]) {continue;}
            new_filter.push(res[i].clone());
            if let (solution, Ok(())) = solve_with_accelerator(start, goal, max_size,
                &new_filter, order_constraints, infer, &mut accelerator(start, goal)) {
                if solution.len() < res.len() &&
                   solution.iter().all(|e| res.iter().any(|f| e == f))
                {
                    max_size = Some(solution.len());
                    res = solution;
                    break;
                }
            }
            new_filter.pop();
        }
        if res.len() == old_len {break;}
    }
    (res, Ok(()))
}
pub fn solve_and_reduce_with_accelerator < T : Clone + PartialEq + Eq + Hash , A > ( start : & [ T ] , goal : & [ T ] , mut max_size : Option < usize > , filter : & [ T ] , order_constraints : & [ ( T , T ) ] , infer : fn ( Solver < T , A > , story : & [ T ] ) -> Option < T > , accelerator : fn ( & [ T ] , & [ T ] ) -> A , ) -> ( Vec < T > , Result < ( ) , Error > ) { let ( mut res , status ) = solve_with_accelerator ( start , goal , max_size , filter , order_constraints , infer , & mut accelerator ( start , goal ) ) ; if status . is_err ( ) { return ( res , status ) } ; // Check that every step is necessary. max_size = Some ( res . len ( ) ) ; let mut new_filter : Vec < T > = filter . into ( ) ; loop { let old_len = res . len ( ) ; for i in ( 0 .. res . len ( ) ) . rev ( ) { if goal . iter ( ) . any ( | e | e == & res [ i ] ) { continue ; } new_filter . push ( res [ i ] . clone ( ) ) ; if let ( solution , Ok ( ( ) ) ) = solve_with_accelerator ( start , goal , max_size , & new_filter , order_constraints , infer , & mut accelerator ( start , goal ) ) { if solution . len ( ) < res . len ( ) && solution . iter ( ) . all ( | e | res . iter ( ) . any ( | f | e == f ) ) { max_size = Some ( solution . len ( ) ) ; res = solution ; break ; } } new_filter . pop ( ) ; } if res . len ( ) == old_len { break ; } } ( res , Ok ( ( ) ) ) }
Solves and reduces the proof to those steps that are necessary.
Solves and reduces the proof to those steps that are necessary .
start
&[T]
goal
&[T]
max_size
Option<usize>
filter
&[T]
order_constraints
&[(T, T)]
infer
fn(Solver<T, A>, story: &[T]) -> Option<T>
story
&[T]
accelerator
fn(&[T], &[T]) -> A
start
&[T]
goal
&[T]
max_size
Option<usize>
filter
&[T]
order_constraints
&[(T, T)]
infer
fn(Solver<T, A>, story: &[T]) -> Option<T>
story
&[T]
accelerator
fn(&[T], &[T]) -> A