func (cs *R1CS) IsSolved(witness []fr.Element, opt backend.ProverOption) error {
	a := make([]fr.Element, len(cs.Constraints))
	b := make([]fr.Element, len(cs.Constraints))
	c := make([]fr.Element, len(cs.Constraints))
	_, err := cs.Solve(witness, a, b, c, opt)
	return err
}
IsSolved returns nil if given witness solves the R1CS and error otherwise
this method wraps cs.Solve() and allocates cs.Solve() inputs
package cs
import (
	"errors"
	"fmt"
	"io"
	"math/big"
	"strings"
	"github.com/fxamacker/cbor/v2"
	"github.com/consensys/gnark/backend"
	"github.com/consensys/gnark/internal/backend/compiled"
	"github.com/consensys/gnark/internal/backend/ioutils"
	"github.com/consensys/gnark-crypto/ecc"
	"text/template"
	"github.com/consensys/gnark-crypto/ecc/bn254/fr"
)
type R1CS struct {
	compiled.R1CS
	Coefficients []fr.Element  
}
func NewR1CS(cs compiled.R1CS, coefficients []big.Int) *R1CS {
	r := R1CS{
		R1CS:         cs,
		Coefficients: make([]fr.Element, len(coefficients)),
	}
	for i := 0; i < len(coefficients); i++ {
		r.Coefficients[i].SetBigInt(&coefficients[i])
	}
	return &r
}
func (cs *R1CS) Solve(witness, a, b, c []fr.Element, opt backend.ProverOption) ([]fr.Element, error) {
	nbWires := cs.NbPublicVariables + cs.NbSecretVariables + cs.NbInternalVariables
	solution, err := newSolution(nbWires, opt.HintFunctions, cs.Coefficients)
	if err != nil {
		return make([]fr.Element, nbWires), err
	}
	if len(witness) != int(cs.NbPublicVariables-1+cs.NbSecretVariables) {  
		return solution.values, fmt.Errorf("invalid witness size, got %d, expected %d = %d (public - ONE_WIRE) + %d (secret)", len(witness), int(cs.NbPublicVariables-1+cs.NbSecretVariables), cs.NbPublicVariables-1, cs.NbSecretVariables)
	}
	if len(a) != len(cs.Constraints) || len(b) != len(cs.Constraints) || len(c) != len(cs.Constraints) {
		return solution.values, errors.New("invalid input size: len(a, b, c) == len(Constraints)")
	}
	solution.solved[0] = true  
	solution.values[0].SetOne()
	copy(solution.values[1:], witness)  
	for i := 0; i < len(witness); i++ {
		solution.solved[i+1] = true
	}
	solution.nbSolved += len(witness) + 1
	defer solution.printLogs(opt.LoggerOut, cs.Logs)
	var check fr.Element
	for i := 0; i < len(cs.Constraints); i++ {
		if err := cs.solveConstraint(cs.Constraints[i], &solution); err != nil {
			return solution.values, err
		}
		a[i], b[i], c[i] = cs.instantiateR1C(cs.Constraints[i], &solution)
		check.Mul(&a[i], &b[i])
		if !check.Equal(&c[i]) {
			if dID, ok := cs.MDebug[i]; ok {
				debugInfoStr := solution.logValue(cs.DebugInfo[dID])
				return solution.values, fmt.Errorf("%w: %s", ErrUnsatisfiedConstraint, debugInfoStr)
			}
			return solution.values, ErrUnsatisfiedConstraint
		}
	}
	if !solution.isValid() {
		panic("solver didn't instantiate all wires")
	}
	return solution.values, nil
}