{*****************************************************************}
{ File : Employee_Classes.sml }
{ created : 9/18/89 SE }
{ last change : 20-Nov-95 TL }
{*****************************************************************}
Class HighSalary in SimpleClass isA Integer with
rule
highsalaryrule: $forall m/Integer
(m >= 60000)
==> (m in HighSalary)
$
end
Class TopSalary in SimpleClass isA HighSalary with
rule
topsalaryrule: $forall m/Integer
(m >= 100000)
==> (m in TopSalary)
$
end
Class Employee in SimpleClass with
attribute
name : String;
salary : Integer;
dept : Department;
boss : Manager
end
Class Manager in SimpleClass isA Employee
end
Class Department in SimpleClass with
attribute
head : Manager
end
Class ProductionDepartment isA Department
end
Class Union in SimpleClass
end
Class WorkerUnion isA Union
end
Class UnionMember in SimpleClass with
attribute
union:Union
end
Class Employee with
rule
bossrule :
$ forall e/Employee m/Manager
(exists d/Department (e dept d) and (d head m) )
==> (e boss m) $
constraint
SalaryBound :
$ forall e/Employee b/Manager x/Integer y/Integer
(e boss b) and (e salary x) and (b salary y)
==> (y >= x) $
end
{*****************************************************************}
{ File : Employee_Instances.sml }
{ created : 9/18/89 SE }
{ last change : 20-Nov-95 TL }
{*****************************************************************}
{ Instances of class Union: }
Individual IGM in WorkerUnion
end
{ ... etc. }
{ Instances of class Department: }
Individual Production in ProductionDepartment with
head
Boss_of_Production : Lloyd
end
{ ... etc. }
{ Instances of class Manager: }
Individual Lloyd in Manager,UnionMember with
dept
LloydsDepartment : Production
salary
LloydsSalary : 100000
union
LloydsUnion : IGM
end
{ ... etc. }
{ Instances of class Employee: }
Individual Michael in Employee with
dept
MichaelsDepartment : Production
salary
MichaelsSalary : 30000
end
Individual Jack in Employee with
dept
JacksDepartment : Production
salary
JacksSalary : 30500
end
{*****************************************************************}
{ File : Employee_Queries.sml }
{ created : 9/18/89 SE }
{ last change : 20-Nov-95 TL }
{ }
{*****************************************************************}
{*****************************************************************}
{ Q u e r y 1 }
{ }
{ ask for all Managers who are socially interested }
{ }
{*****************************************************************}
QueryClass SI_Manager isA Manager,UnionMember with
retrieved_attribute
union : Union;
salary : Integer
end
{*****************************************************************}
{ Q u e r y 2 }
{ }
{ ask for all Managers who have a high salary }
{ }
{*****************************************************************}
QueryClass Well_off_Manager isA Manager with
constraint
well_off_rule : $ exists s/HighSalary
(this salary s) $
end
{*****************************************************************}
{ Q u e r y 3 }
{ }
{ ask for all Managers who are social interested and for the }
{ Department they are the head of }
{ }
{*****************************************************************}
QueryClass Well_off_SI_Manager3 isA Manager,UnionMember with
retrieved_attribute
union : Union
computed_attribute
head_of : Department
constraint
well_off_head_of_rule : $ exists s/HighSalary
(this salary s) and
(head_of head this) $
end
{ ... etc. }