example NewDemoPsuedo

options
	require_consistency=false
	dont_validate_unsafe=true
	always_reload=true
	timeout = 60
#		prover=monoidal 
		

typeside Ty = literal {
	external_types
		Integer -> "java.lang.Integer"
		Float -> "java.math.BigDecimal"
		String -> "java.lang.String"
	external_parsers 
		Float -> "x => java.math.BigDecimal.valueOf(java.lang.Double.parseDouble(x))"
		Integer -> "x => java.lang.Integer.parseInt(x)"
		String -> "x => x"
	external_functions
		"+" : Float,Float->Float = "(x, y) => x.add(y)"	
		"*" : Float,Float->Float = "(x, y) => x.multiply(y)"	
		"-" : Float,Float->Float = "(x, y) => x.subtract(y)"	
		"/" : Float,Float->Float = "(x, y) => x.divide(y)"	
		"MAX" : Float,Float->Float = "(x, y) => x.max(y)"
		"MIN" : Float,Float->Float = "(x, y) => x.min(y)"		
	equations
		
}		

#schema S1 = importFromJDBC <url>
schema Olog1Schema = literal : Ty {
	entity Patient
	attributes ID first_name last_name birthdate create_date : String

	entity Visit
	attributes ID patient_id visit_date : String

	entity Observation
	attributes ID visit_id clinician_id obs_type observation : String
}
constraints Olog1Constraints = literal : Olog1Schema {
	forall x y : Observation where x.ID = y.ID -> where x = y
	forall x y : Visit where x.ID = y.ID -> where x = y
	forall x y : Patient where x.ID = y.ID -> where x = y
	forall x : Observation -> exists y : Visit where x.visit_id = y.ID
	forall x : Visit -> exists y : Patient where x.patient_id = y.ID
}
schema Olog2Schema = literal : Ty {
	entity Prescription
	attributes ID patient_id date details : String

	entity Patient 
	attributes ID fname lname dob : String

	entity Observation
	attributes ID patient_id clinician_id obs_type obs_date observation : String
}
constraints Olog2Constraints = literal : Olog2Schema {
	forall x y : Observation where x.ID = y.ID -> where x = y
	forall x y : Prescription where x.ID = y.ID -> where x = y
	forall x y : Patient where x.ID = y.ID -> where x = y
	forall x : Prescription -> exists y : Patient where x.patient_id = y.ID
	forall x : Observation -> exists y : Patient where x.patient_id = y.ID
}
#instance O1 = importJdbc <url>
instance Olog1Data = literal : Olog1Schema {
	generators
		p1 p2 p3 : Patient
		v1 v2 v3 : Visit
		o1 o2 o3 : Observation
	equations
		p1.ID = 937189 p1.first_name = john p1.last_name = doe 
		p1.birthdate = 340465020 p1.create_date = 1187438212 	
		p2.ID = 937190 p2.first_name = amrit p2.last_name = kumar 
		p2.birthdate = 246222505 p2.create_date = 1187444008
		p3.ID = 937191 p3.first_name = alexandra p3.last_name = grant 
		p3.birthdate = 121408849 p3.create_date = 1187445155 	

		v1.ID = 1237827 v1.patient_id = 937189 v1.visit_date = 1187438212
		v2.ID = 1237828 v2.patient_id = 937190 v2.visit_date = 1187444008
		v3.ID = 1237829 v3.patient_id = 937191 v3.visit_date = 1187445155

		o1.ID = 487298329 o1.visit_id = 1237827 o1.clinician_id = 562 
		o1.obs_type = HR o1.observation = 114
		o2.ID = 487298330 o2.visit_id = 1237827 o2.clinician_id = 562 
		o2.obs_type = WT o2.observation = 180
		o3.ID = 487298331 o3.visit_id = 1237827 o3.clinician_id = 562 
		o3.obs_type = BP o3.observation = "130/82"
}

instance Olog2Data = literal : Olog2Schema {
generators
		p1 p2 p3 : Patient
		v1 v2 v3 : Prescription
		o1 o2 o3 : Observation
	equations
		p1.ID = 25234 p1.fname = alexandra p1.lname = grant 
		p1.dob = 121408849
		p2.ID = 25235 p2.fname = vincent p2.lname = "von hoff" 
		p2.dob = 409235232
		p3.ID = 25236 p3.fname = brian p3.lname = tsai 
		p3.dob = 380665171 	

		v1.ID = 675345 v1.patient_id = 25234 v1.date = 1639676732
		v1.details = Enalapril
		v2.ID = 675346 v2.patient_id = 25234 v2.date = 1639696544
		v2.details = chlorothiazide
		v3.ID = 675347 v3.patient_id = 25235 v3.date = 1639704522
		v3.details = lisinopril

		o1.ID = 154298449 o1.patient_id = 25234 o1.clinician_id = 132 
		o1.obs_type = HR o1.obs_date = 1639676732 o1.observation=116
		o2.ID = 154298450 o2.patient_id = 25234 o2.clinician_id = 132 
		o2.obs_type = WT o2.obs_date = 1639676732 o2.observation=220
		o3.ID = 154298451 o3.patient_id = 25234 o3.clinician_id = 132 
		o3.obs_type = BP o3.obs_date = 1639676732 o3.observation="132/82"

}
command check1 = check Olog1Constraints Olog1Data
command check2 = check Olog2Constraints Olog2Data

schema_colimit C = pseudo_quotient  Olog1Schema + Olog2Schema : Ty {
	entity_isomorphisms
		p : Olog1Schema.Patient -> Olog2Schema.Patient
		o : Olog1Schema.Observation -> Olog2Schema.Observation
	equations
		forall x:Olog1Schema.Patient,  x.first_name = x.p.fname #x.first_name = uppercase(x.fname)
		forall x:Olog1Schema.Patient,     x.last_name = x.p.lname 
		forall x:Olog1Schema.Patient,     x.birthdate = x.p.dob #x.bd = x.dob+1
		forall x:Olog1Schema.Observation,     x.ID = x.o.ID
		forall x:Olog1Schema.Observation,     x.observation = x.o.observation
		forall x:Olog1Schema.Observation,     x.clinician_id = x.o.clinician_id  
		forall x:Olog1Schema.Observation,     x.obs_type = x.o.obs_type
}

instance Olog1DataFwd = sigma (getMapping C Olog1Schema) Olog1Data
instance Olog2DataFwd = sigma (getMapping C Olog2Schema) Olog2Data

constraints Olog1ConstraintsFwd = sigma (getMapping C Olog1Schema) Olog1Constraints
constraints Olog2ConstraintsFwd = sigma (getMapping C Olog2Schema) Olog2Constraints


instance CoProd = coproduct Olog1DataFwd + Olog2DataFwd  : getSchema C

constraints Rules = literal : getSchema C {
	imports Olog1ConstraintsFwd Olog2ConstraintsFwd	
	
	forall x y : Olog1Schema_Patient where x.first_name=y.first_name x.last_name=y.last_name 
	-> where x=y

	forall x y : Olog2Schema_Observation where x.obs_date = y.obs_date 
	 -> where x.o_inv.visit_id = y.o_inv.visit_id

	forall x y : Olog1Schema_Observation where x.visit_id = y.visit_id
	 -> where x.o.patient_id = y.o.patient_id

	forall x : Olog1Schema_Observation y : Olog1Schema_Visit z : Olog1Schema_Patient z2 : Olog2Schema_Patient 
	where x.visit_id = y.ID z.ID = y.patient_id  x.o.patient_id = z2.ID 
	 -> where z = z2.p_inv

	forall x y : Olog1Schema_Observation where x.visit_id = y.visit_id 
	-> where x.o.obs_date = y.o.obs_date 

	forall x : Olog1Schema_Observation y : Olog1Schema_Visit where x.visit_id = y.ID 
	-> where y.visit_date = x.o.obs_date
}

instance Colim = chase Rules CoProd

mapping M = getPseudo C

instance L = sigma M Colim 

instance Olog1DataBkwd = delta (getMapping C Olog1Schema) Colim
instance Olog2DataBkwd = delta (getMapping C Olog2Schema) Colim
Keywords:

typeside_literal
chase
getPseudo
constraints_literal
sigma
delta
schema_literal
sigma
instance_literal
check
pseudo_quotient
coproduct

Options:




instance Olog1Data

Observation
IDIDvisit_idclinician_idobs_typeobservation
04872983291237827562HR114
14872983301237827562WT180
24872983311237827562BP130/82
Patient
IDIDfirst_namelast_namebirthdatecreate_date
3937189johndoe3404650201187438212
4937190amritkumar2462225051187444008
5937191alexandragrant1214088491187445155
Visit
IDIDpatient_idvisit_date
612378279371891187438212
712378289371901187444008
812378299371911187445155


instance Olog2Data

Observation
IDIDpatient_idclinician_idobs_typeobs_dateobservation
015429844925234132HR1639676732116
115429845025234132WT1639676732220
215429845125234132BP1639676732132/82
Patient
IDIDfnamelnamedob
325234alexandragrant121408849
425235vincentvon hoff409235232
525236briantsai380665171
Prescription
IDIDpatient_iddatedetails
6675345252341639676732Enalapril
7675346252341639696544chlorothiazide
8675347252351639704522lisinopril


instance Olog1DataFwd

Olog1Schema_Observation
IDIDvisit_idclinician_idobs_typeobservationo
04872983291237827562HR1149
14872983301237827562WT18010
24872983311237827562BP130/8211
Olog1Schema_Patient
IDIDfirst_namelast_namebirthdatecreate_datep
3937189johndoe340465020118743821212
4937190amritkumar246222505118744400813
5937191alexandragrant121408849118744515514
Olog1Schema_Visit
IDIDpatient_idvisit_date
612378279371891187438212
712378289371901187444008
812378299371911187445155
Olog2Schema_Observation
IDIDpatient_idclinician_idobs_typeobs_dateobservationo_inv
9487298329?0562HR?11140
10487298330?2562WT?31801
11487298331?4562BP?5130/822
Olog2Schema_Patient
IDIDfnamelnamedobp_inv
12?6johndoe3404650203
13?7amritkumar2462225054
14?8alexandragrant1214088495
Olog2Schema_Prescription
IDIDpatient_iddatedetails


instance Olog2DataFwd

Olog1Schema_Observation
IDIDvisit_idclinician_idobs_typeobservationo
0154298449?0132HR1166
1154298450?1132WT2207
2154298451?2132BP132/828
Olog1Schema_Patient
IDIDfirst_namelast_namebirthdatecreate_datep
3?3alexandragrant121408849?49
4?5vincentvon hoff409235232?610
5?7briantsai380665171?811
Olog1Schema_Visit
IDIDpatient_idvisit_date
Olog2Schema_Observation
IDIDpatient_idclinician_idobs_typeobs_dateobservationo_inv
615429844925234132HR16396767321160
715429845025234132WT16396767322201
815429845125234132BP1639676732132/822
Olog2Schema_Patient
IDIDfnamelnamedobp_inv
925234alexandragrant1214088493
1025235vincentvon hoff4092352324
1125236briantsai3806651715
Olog2Schema_Prescription
IDIDpatient_iddatedetails
12675345252341639676732Enalapril
13675346252341639696544chlorothiazide
14675347252351639704522lisinopril


instance CoProd

Olog1Schema_Observation
IDIDvisit_idclinician_idobs_typeobservationo
04872983291237827562HR11415
14872983301237827562WT18016
24872983311237827562BP130/8217
3154298449?0132HR11618
4154298450?1132WT22019
5154298451?2132BP132/8220
Olog1Schema_Patient
IDIDfirst_namelast_namebirthdatecreate_datep
6937189johndoe340465020118743821221
7937190amritkumar246222505118744400822
8937191alexandragrant121408849118744515523
9?3alexandragrant121408849?424
10?5vincentvon hoff409235232?625
11?7briantsai380665171?826
Olog1Schema_Visit
IDIDpatient_idvisit_date
1212378279371891187438212
1312378289371901187444008
1412378299371911187445155
Olog2Schema_Observation
IDIDpatient_idclinician_idobs_typeobs_dateobservationo_inv
15487298329?9562HR?101140
16487298330?11562WT?121801
17487298331?13562BP?14130/822
1815429844925234132HR16396767321163
1915429845025234132WT16396767322204
2015429845125234132BP1639676732132/825
Olog2Schema_Patient
IDIDfnamelnamedobp_inv
21?15johndoe3404650206
22?16amritkumar2462225057
23?17alexandragrant1214088498
2425234alexandragrant1214088499
2525235vincentvon hoff40923523210
2625236briantsai38066517111
Olog2Schema_Prescription
IDIDpatient_iddatedetails
27675345252341639676732Enalapril
28675346252341639696544chlorothiazide
29675347252351639704522lisinopril


instance Colim

Olog1Schema_Observation
IDIDvisit_idclinician_idobs_typeobservationo
0154298451?0132BP132/8215
1154298450?0132WT22016
2154298449?0132HR11617
34872983291237827562HR11418
44872983301237827562WT18019
54872983311237827562BP130/8220
Olog1Schema_Patient
IDIDfirst_namelast_namebirthdatecreate_datep
6937191alexandragrant121408849118744515521
7937189johndoe340465020118743821222
8?1vincentvon hoff409235232?223
9?3briantsai380665171?424
10937190amritkumar246222505118744400825
Olog1Schema_Visit
IDIDpatient_idvisit_date
11?09371911639676732
1212378279371891187438212
1312378289371901187444008
1412378299371911187445155
Olog2Schema_Observation
IDIDpatient_idclinician_idobs_typeobs_dateobservationo_inv
1515429845125234132BP1639676732132/820
1615429845025234132WT16396767322201
1715429844925234132HR16396767321162
18487298329?5562HR11874382121143
19487298330?5562WT11874382121804
20487298331?5562BP1187438212130/825
Olog2Schema_Patient
IDIDfnamelnamedobp_inv
2125234alexandragrant1214088496
22?5johndoe3404650207
2325235vincentvon hoff4092352328
2425236briantsai3806651719
25?6amritkumar24622250510
Olog2Schema_Prescription
IDIDpatient_iddatedetails
26675345252341639676732Enalapril
27675346252341639696544chlorothiazide
28675347252351639704522lisinopril


instance Olog1DataBkwd

Observation
IDIDvisit_idclinician_idobs_typeobservation
0154298451?0132BP132/82
1154298450?0132WT220
2154298449?0132HR116
34872983291237827562HR114
44872983301237827562WT180
54872983311237827562BP130/82
Patient
IDIDfirst_namelast_namebirthdatecreate_date
6937191alexandragrant1214088491187445155
7937189johndoe3404650201187438212
8?1vincentvon hoff409235232?2
9?3briantsai380665171?4
10937190amritkumar2462225051187444008
Visit
IDIDpatient_idvisit_date
11?09371911639676732
1212378279371891187438212
1312378289371901187444008
1412378299371911187445155


instance Olog2DataBkwd

Observation
IDIDpatient_idclinician_idobs_typeobs_dateobservation
015429845125234132BP1639676732132/82
115429845025234132WT1639676732220
215429844925234132HR1639676732116
3487298329?0562HR1187438212114
4487298330?0562WT1187438212180
5487298331?0562BP1187438212130/82
Patient
IDIDfnamelnamedob
625234alexandragrant121408849
7?0johndoe340465020
825235vincentvon hoff409235232
925236briantsai380665171
10?1amritkumar246222505
Prescription
IDIDpatient_iddatedetails
11675345252341639676732Enalapril
12675346252341639696544chlorothiazide
13675347252351639704522lisinopril


instance L

Observation
IDobs_dateIDvisit_idobservationobs_typeclinician_idpatient_id
01639676732154298451?0132/82BP13225234
11639676732154298450?0220WT13225234
21639676732154298449?0116HR13225234
311874382124872983291237827114HR562?1
411874382124872983301237827180WT562?1
511874382124872983311237827130/82BP562?1
Patient
IDlast_nameOlog2Schema_Patient_IDcreate_datefirst_nameIDbirthdate
6grant252341187445155alexandra937191121408849
7doe?11187438212john937189340465020
8von hoff25235?2vincent?3409235232
9tsai25236?4brian?5380665171
10kumar?61187444008amrit937190246222505
Prescription
IDdetailsdateIDpatient_id
11Enalapril163967673267534525234
12chlorothiazide163969654467534625234
13lisinopril163970452267534725235
Visit
IDpatient_idvisit_dateID
149371911639676732?0
1593718911874382121237827
1693719011874440081237828
1793719111874451551237829


command check1

Satisfied

command check2

Satisfied