|
FUNCTION member_of (val : GENERIC:g, spc : maths_space) : LOGICAL; FUNCTION fedex ( val : AGGREGATE OF GENERIC : x ; i : INTEGER ) : GENERIC : x ; RETURN ( val [ i ] ) ; END_FUNCTION ; LOCAL v : maths_value := simplify_maths_value ( convert_to_maths_value ( val ) ) ; vtypes : SET OF STRING := stripped_typeof ( v ) ; s : maths_space := simplify_maths_space ( spc ) ; stypes : SET OF STRING := stripped_typeof ( s ) ; tmp_int : INTEGER ; tmp_real : REAL ; tmp_cmplx : complex_number_literal ; lgcl , cum : LOGICAL ; vspc , sspc : maths_space ; smem : SET OF maths_value ; factors : LIST OF maths_space ; END_LOCAL ; IF NOT EXISTS ( s ) THEN RETURN ( FALSE ) ; END_IF ; IF NOT EXISTS ( v ) THEN RETURN ( s = the_generics ) ; END_IF ; IF ( 'generic_expression' IN vtypes ) AND NOT ( 'maths_space' IN vtypes ) AND NOT ( 'maths_function' IN vtypes ) AND NOT ( 'complex_number_literal' IN vtypes ) THEN IF has_values_space ( v ) THEN vspc := values_space_of ( v ) ; IF subspace_of ( vspc , s ) THEN RETURN ( TRUE ) ; END_IF ; IF NOT compatible_spaces ( vspc , s ) THEN RETURN ( FALSE ) ; END_IF ; RETURN ( UNKNOWN ) ; END_IF ; RETURN ( UNKNOWN ) ; END_IF ; IF 'elementary_space' IN stypes THEN CASE s \ elementary_space . space_id OF es_numbers : RETURN ( ( 'number' IN vtypes ) OR ( 'complex_number_literal' IN vtypes ) ) ; es_complex_numbers : RETURN ( 'complex_number_literal' IN vtypes ) ; es_reals : RETURN ( ( 'real' IN vtypes ) AND NOT ( 'integer' IN vtypes ) ) ; es_integers : RETURN ( 'integer' IN vtypes ) ; es_logicals : RETURN ( 'logical' IN vtypes ) ; es_booleans : RETURN ( 'boolean' IN vtypes ) ; es_strings : RETURN ( 'string' IN vtypes ) ; es_binarys : RETURN ( 'binary' IN vtypes ) ; es_maths_spaces : RETURN ( 'maths_space' IN vtypes ) ; es_maths_functions : RETURN ( 'maths_function' IN vtypes ) ; es_generics : RETURN ( TRUE ) ; END_CASE ; END_IF ; IF 'finite_integer_interval' IN stypes THEN IF 'integer' IN vtypes THEN tmp_int := v ; RETURN ( { s \ finite_integer_interval . min <= tmp_int <= s \ finite_integer_interval . max } ) ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'integer_interval_from_min' IN stypes THEN IF 'integer' IN vtypes THEN tmp_int := v ; RETURN ( s \ integer_interval_from_min . min <= tmp_int ) ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'integer_interval_to_max' IN stypes THEN IF 'integer' IN vtypes THEN tmp_int := v ; RETURN ( tmp_int <= s \ integer_interval_to_max . max ) ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'finite_real_interval' IN stypes THEN IF ( 'real' IN vtypes ) AND NOT ( 'integer' IN vtypes ) THEN tmp_real := v ; IF s \ finite_real_interval . min_closure = closed THEN IF s \ finite_real_interval . max_closure = closed THEN RETURN ( { s \ finite_real_interval . min <= tmp_real <= s \ finite_real_interval . max } ) ; ELSE RETURN ( { s \ finite_real_interval . min <= tmp_real < s \ finite_real_interval . max } ) ; END_IF ; ELSE IF s \ finite_real_interval . max_closure = closed THEN RETURN ( { s \ finite_real_interval . min < tmp_real <= s \ finite_real_interval . max } ) ; ELSE RETURN ( { s \ finite_real_interval . min < tmp_real < s \ finite_real_interval . max } ) ; END_IF ; END_IF ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'real_interval_from_min' IN stypes THEN IF ( 'real' IN vtypes ) AND NOT ( 'integer' IN vtypes ) THEN tmp_real := v ; IF s \ real_interval_from_min . min_closure = closed THEN RETURN ( s \ real_interval_from_min . min <= tmp_real ) ; ELSE RETURN ( s \ real_interval_from_min . min < tmp_real ) ; END_IF ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'real_interval_to_max' IN stypes THEN IF ( 'real' IN vtypes ) AND NOT ( 'integer' IN vtypes ) THEN tmp_real := v ; IF s \ real_interval_to_max . max_closure = closed THEN RETURN ( tmp_real <= s \ real_interval_to_max . max ) ; ELSE RETURN ( tmp_real < s \ real_interval_to_max . max ) ; END_IF ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'cartesian_complex_number_region' IN stypes THEN IF 'complex_number_literal' IN vtypes THEN RETURN ( member_of ( v \ complex_number_literal . real_part , s \ cartesian_complex_number_region . real_constraint ) AND member_of ( v \ complex_number_literal . imag_part , s \ cartesian_complex_number_region . imag_constraint ) ) ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'polar_complex_number_region' IN stypes THEN IF 'complex_number_literal' IN vtypes THEN tmp_cmplx := v ; tmp_cmplx . real_part := tmp_cmplx . real_part - s \ polar_complex_number_region . centre . real_part ; tmp_cmplx . imag_part := tmp_cmplx . imag_part - s \ polar_complex_number_region . centre . imag_part ; tmp_real := SQRT ( tmp_cmplx . real_part ** 2 + tmp_cmplx . imag_part ** 2 ) ; IF NOT member_of ( tmp_real , s \ polar_complex_number_region . distance_constraint ) THEN RETURN ( FALSE ) ; END_IF ; IF tmp_real = 0.0 THEN RETURN ( TRUE ) ; END_IF ; tmp_real := atan2 ( tmp_cmplx . imag_part , tmp_cmplx . real_part ) ; RETURN ( member_of ( tmp_real , s \ polar_complex_number_region . direction_constraint ) OR member_of ( tmp_real + 2.0 * PI , s \ polar_complex_number_region . direction_constraint ) ) ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'finite_space' IN stypes THEN smem := s \ finite_space . members ; cum := FALSE ; REPEAT i := 1 TO SIZEOF ( smem ) ; cum := cum OR equal_maths_values ( v , smem [ i ] ) ; IF cum = TRUE THEN RETURN ( TRUE ) ; END_IF ; END_REPEAT ; RETURN ( cum ) ; END_IF ; IF 'uniform_product_space' IN stypes THEN IF 'list' IN vtypes THEN IF SIZEOF ( v ) = s \ uniform_product_space . exponent THEN sspc := s \ uniform_product_space . base ; cum := TRUE ; REPEAT i := 1 TO SIZEOF ( v ) ; cum := cum AND member_of ( v [ i ] , sspc ) ; IF cum = FALSE THEN RETURN ( FALSE ) ; END_IF ; END_REPEAT ; RETURN ( cum ) ; END_IF ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'listed_product_space' IN stypes THEN IF 'list' IN vtypes THEN factors := s \ listed_product_space . factors ; IF SIZEOF ( v ) = SIZEOF ( factors ) THEN cum := TRUE ; REPEAT i := 1 TO SIZEOF ( v ) ; cum := cum AND member_of ( v [ i ] , factors [ i ] ) ; IF cum = FALSE THEN RETURN ( FALSE ) ; END_IF ; END_REPEAT ; RETURN ( cum ) ; END_IF ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'extended_tuple_space' IN stypes THEN IF 'list' IN vtypes THEN sspc := s \ extended_tuple_space . base ; tmp_int := space_dimension ( sspc ) ; IF SIZEOF ( v ) >= tmp_int THEN cum := TRUE ; REPEAT i := 1 TO tmp_int ; cum := cum AND member_of ( v [ i ] , factor_space ( sspc , i ) ) ; IF cum = FALSE THEN RETURN ( FALSE ) ; END_IF ; END_REPEAT ; sspc := s \ extended_tuple_space . extender ; REPEAT i := tmp_int + 1 TO SIZEOF ( v ) ; cum := cum AND member_of ( v [ i ] , sspc ) ; IF cum = FALSE THEN RETURN ( FALSE ) ; END_IF ; END_REPEAT ; RETURN ( cum ) ; END_IF ; END_IF ; RETURN ( FALSE ) ; END_IF ; IF 'function_space' IN stypes THEN IF 'maths_function' IN vtypes THEN vspc := v \ maths_function . domain ; sspc := s \ function_space . domain_argument ; CASE s \ function_space . domain_constraint OF sc_equal : cum := equal_maths_spaces ( vspc , sspc ) ; sc_subspace : cum := subspace_of ( vspc , sspc ) ; sc_member : cum := member_of ( vspc , sspc ) ; END_CASE ; IF cum = FALSE THEN RETURN ( FALSE ) ; END_IF ; vspc := v \ maths_function . range ; sspc := s \ function_space . range_argument ; CASE s \ function_space . range_constraint OF sc_equal : cum := cum AND equal_maths_spaces ( vspc , sspc ) ; sc_subspace : cum := cum AND subspace_of ( vspc , sspc ) ; sc_member : cum := cum AND member_of ( vspc , sspc ) ; END_CASE ; RETURN ( cum ) ; END_IF ; RETURN ( FALSE ) ; END_IF ; RETURN ( UNKNOWN ) ; END_FUNCTION; -- member_of |
|
public class FMember_of public static Value run(SdaiContext _context, Value val, Value spc) |