

1  =head1 NAME 


2  


3  Context("Inequalities"), Context("InequalitiesOnly")  Provides contexts that 


4  allow intervals to be specified as inequalities. 


5  


6  =head1 DESCRIPTION 


7  


8  Implements contexts that provides for inequalities that produce 


9  the cooresponding Interval, Set or Union MathObjects. There are 


10  two such contexts: Context("Inequalities"), in which both 


11  intervals and inequalities are defined, and Context("InequalitiesOnly"), 


12  which allows only inequalities as a means of producing intervals. 


13  


14  =head1 USAGE 


15  


16  loadMacros("contextInequalities.pl"); 


17  


18  Context("Inequalities"); 


19  $S1 = Compute("1 < x <= 4"); 


20  $S2 = Inequality("(1,4]"); # force interval to be inequality 


21  


22  Context("InequalitiesOnly"); 


23  $S1 = Compute("1 < x <= 4"); 


24  $S2 = Inequality("(1,4]"); # generates an error 


25  


26  $S3 = Compute("x < 2 or x > 2"); # forms a Union 


27  $S4 = Compute("x = 1"); # forms a Set 


28  


29  You can set the "noneWord" flag to specify the string to 


30  use when the inequalities specify the empty set. By default, 


31  it is "NONE", but you can change it to other strings. Be sure 


32  that you use a string that is defined in the Context, however, 


33  if you expect the student to be able to enter it. For example 


34  


35  Context("Inequalities"); 


36  Context()>constants>add(EmptySet => Set()); 


37  Context()>flags>set(noneWord=>"EmptySet"); 


38  


39  creates an empty set as a named constant and uses that name. 


40  


41  Inequalities and interval notation both can coexist side by 


42  side, but you may wish to convert from one to the other. 


43  Use Inequality() to convert from an Interval, Set or Union 


44  to an Inequality, and use Interval(), Set(), or Union() to 


45  convert from an Inequality object to one in interval notation. 


46  For example: 


47  


48  $I0 = Compute("(1,2]"); # the interval (1,2] 


49  $I1 = Inequality($I); # the inequality 1 < x <= 2 


50  


51  $I0 = Compute("1 < x <= 2"); # the inequality 1 < x <= 2 


52  $I1 = Interval($I0); # the interval (1,2] 


53  


54  Note that ineqaulities and inervals can be compared and combined 


55  regardless of the format, so $I0 == $I1 is true in either example 


56  above. 


57  


58  =cut 


59  
1  loadMacros("MathObjects.pl"); 
60  loadMacros("MathObjects.pl"); 
2  
61  
3  sub _contextInequalities_init {Inequalities::Init()} 
62  sub _contextInequalities_init {Inequalities::Init()} 
4  


5  =head1 Context("Inequalities"), Context("InequalitiesOnly") 


6  


7  ######################################################################### 


8  # 


9  # Implements contexts that provides for inequalities that produce 


10  # the cooresponding Interval, Set or Union MathObjects. There are 


11  # two such contexts: Context("Inequalities"), in which both 


12  # intervals and inequalities are defined, and Context("InequalitiesOnly"), 


13  # which allows only inequalities as a means of producing intervals. 


14  # 


15  # Usage: loadMacros("contextInequalities.pl"); 


16  # 


17  # Context("Inequalities"); 


18  # $S1 = Compute("1 < x <= 4"); 


19  # $S2 = Inequality("(1,4]"); # force interval to be inequality 


20  # 


21  # Context("InequalitiesOnly"); 


22  # $S1 = Compute("1 < x <= 4"); 


23  # $S2 = Inequality("(1,4]"); # generates an error 


24  # 


25  # $S3 = Compute("x < 2 or x > 2"); # forms a Union 


26  # $S4 = Compute("x = 1"); # forms a Set 


27  # 


28  # You can set the "noneWord" flag to specify the string to 


29  # use when the inequalities specify the empty set. By default, 


30  # it is "NONE", but you can change it to other strings. Be sure 


31  # that you use a string that is defined in the Context, however, 


32  # if you expect the student to be able to enter it. For example 


33  # 


34  # Context("Inequalities"); 


35  # Context()>constants>add(EmptySet => Set()); 


36  # Context()>flags>set(noneWord=>"EmptySet"); 


37  # 


38  # creates an empty set as a named constant and uses that name. 


39  # 


40  # Inequalities and interval notation both can coexist side by 


41  # side, but you may wish to convert from one to the other. 


42  # Use Inequality() to convert from an Interval, Set or Union 


43  # to an Inequality, and use Interval(), Set(), or Union() to 


44  # convert from an Inequality object to one in interval notation. 


45  # For example: 


46  # 


47  # $I0 = Compute("(1,2]"); # the interval (1,2] 


48  # $I1 = Inequality($I); # the inequality 1 < x <= 2 


49  # 


50  # $I0 = Compute("1 < x <= 2"); # the inequality 1 < x <= 2 


51  # $I1 = Interval($I0); # the interval (1,2] 


52  # 


53  # Note that ineqaulities and inervals can be compared and combined 


54  # regardless of the format, so $I0 == $I1 is true in either example 


55  # above. 


56  # 


57  ###################################################################### 


58  


59  =cut 


60  
63  
61  package Inequalities; 
64  package Inequalities; 
62  
65  
63  # 
66  # 
64  # Sets up the two inequality contexts 
67  # Sets up the two inequality contexts 