# reflexive and transitive, but neither symmetric nor antisymmetric. my @s = 1..3; my @p = map { $l=$_; map { "($l,$_)" } @s } @s; my $k = @p; for (my $i=0;$i<2**$k;$i++) { my %R; for (my $j=0;$j<$k;$j++) { $R{$p[$j]} = 1 if ($i & (1<<$j)); } next unless reflexive(\%R); next unless transitive(\%R); next if symmetric(\%R); next if antisymmetric(\%R); print "{",join(",",sort keys %R),"}\n"; } sub reflexive($) { my $r = shift; foreach my $a (@s) { return 0 unless $r->{"($a,$a)"}; } return 1; } sub transitive($) { my $r = shift; foreach my $a (@s) { foreach my $b (@s) { next unless $r->{"($a,$b)"}; foreach my $c (@s) { next unless $r->{"($b,$c)"}; return 0 unless $r->{"($a,$c)"}; } } } return 1; } sub symmetric($) { my $r = shift; foreach my $a (@s) { foreach my $b (@s) { next unless $r->{"($a,$b)"}; return 0 unless $r->{"($b,$a)"}; } } return 1; } sub antisymmetric($) { my $r = shift; foreach my $a (@s) { foreach my $b (@s) { next unless $r->{"($a,$b)"}; next unless $r->{"($b,$a)"}; return 0 unless $a==$b; } } return 1; }