
diagnostics=good
Eq=
!for i=1 to $codim
 e_=!trim $(eq$i)
 !if $e_=$empty
  error=empty_data
  !exit
 !endif
 e_=!char 1 to $eqlim of $e_
 e_=!lower $e_
 e_=!rawmath $e_
 eq$i=$e_
 Eq=$Eq+($e_)
!next i

v_=!varlist $Eq
v_=!listunion $var2 and $v_
n_=!itemcnt $v_
!if $n_>$objdim
  error=illegal_var
  !exit
!endif

!for v in $var2
 Eq=!mathsubst $v=t in $Eq
!next v
r=!random -10,10
lintest=!exec pari print(poldegree($Eq))\
	print(subst($Eq-Pol($Eq,t),t,$r))
!distribute lines $lintest into deg, rest
rest=!trim $rest
!if $rest=$empty
 error=bad_data
 !exit
!endif
!ifval $rest!=0 or $deg>1
 error=non_linear
 !exit
!endif

!for i=1 to $codim
 e_=$(eq$i)
 w=!item $i of $var1
 !for p=1 to $objdim+1
  E_=$e_
  !for v in $var2
   E_=!mathsubst $v=($($(v)_$p)) in $E_
  !next v
  E_=$[$E_]
  !if NaN isin $E_ or Inf isin $E_
   error=bad_data
   !exit
  !endif
  !ifval $E_!=$($(w)_$p)
   diagnostics=bad $p
   !exit
  !endif
 !next p
!next i

