View difference between Paste ID: 4ULWk6b7 and rzW9KkPC
SHOW: | | - or go back to the newest paste.
1
#import: member(ele,set).
2-
#import: written-on(word,paper).
2+
3
4
my-minus-one(N,M) <->  (N > 1)  &  (M = N-1)
5
6
forall x. same(x,x)
7
8
9-
legal-pad(paper) <-> min-elements(1, paper)
9+
exactly-n-elements(1,set) <->
10
(exists set ele.  
11-
exactly-n-elements(1,paper) <->
11+
    (   member(ele,set) 
12-
(exists paper word.  
12+
      & ~(exists other-ele.
13-
    (   written-on(word,paper) 
13+
           (  member(other-ele,set) 
14-
      & ~(exists other-word.
14+
             & ~same(other-ele,ele)))))
15-
           (  written-on(other-word,paper) 
15+
16-
             & ~same(other-word,word)))))
16+
exactly-n-elements(2,set) <->
17
(exists set ele1 ele2. 
18-
exactly-n-elements(2,paper) <->
18+
  (  member(ele1,set) 
19-
(exists paper word1 word2. 
19+
   & member(ele2,set) 
20-
  (  written-on(word1,paper) 
20+
   & ~same(ele1,ele2)   
21-
   & written-on(word2,paper) 
21+
   & ~ (exists other-ele. 
22-
   & ~same(word1,word2)   
22+
         (   member(other-ele,set) 
23-
   & ~ (exists other-word. 
23+
          & ~same(other-ele,ele1) 
24-
         (   written-on(other-word,paper) 
24+
          & ~same(other-ele,ele2)))))
25-
          & ~same(other-word,word1) 
25+
26-
          & ~same(other-word,word2)))))
26+
exactly-n-elements(N,set) <-> 
27
   range-elements(N,N,set)  
28-
exactly-n-elements(N,paper) <-> 
28+
29-
   range-elements(N,N,paper)  
29+
range-elements(N,M,set) <-> 
30
 (exists set.
31-
range-elements(N,M,paper) <-> 
31+
  ( min-elements(N,set) 
32-
 (exists paper.
32+
    & max-elements(M,set)))
33-
  ( min-elements(N,paper) 
33+
34-
    & max-elements(M,paper)))
34+
min-elements(1,set) <-> 
35
 (exists set ele1.
36-
min-elements(1,paper) <-> 
36+
     (member(ele1,set)))
37-
 (exists paper word1.
37+
38-
     (written-on(word1,paper)))
38+
min-elements(2,set) <->
39
 (exists set ele1 ele2. 
40-
min-elements(2,paper) <->
40+
   (  member(ele1,set) 
41-
 (exists paper word1 word2. 
41+
    & member(ele2,set)
42-
   (  written-on(word1,paper) 
42+
    & ~same(ele1,ele2)))
43-
    & written-on(word2,paper)
43+
44-
    & ~same(word1,word2)))
44+
max-elements(2,set) <->  
45
(exists set ele1 ele2. 
46-
max-elements(2,paper) <->  
46+
   (  member(ele1,set) 
47-
(exists paper word1 word2. 
47+
    & member(ele2,set) 
48-
   (  written-on(word1,paper) 
48+
    &  ~(exists other-ele.
49-
    & written-on(word2,paper) 
49+
          (  member(other-ele,set) 
50-
    &  ~(exists other-word.
50+
            & ~same(other-ele,ele1)
51-
          (  written-on(other-word,paper) 
51+
            & ~same(other-ele,ele2)))))
52-
            & ~same(other-word,word1)
52+
53-
            & ~same(other-word,word2)))))
53+
% exists a set with no elements
54
exactly-n-elements(0,set) <->
55-
% exists a paper with no elements
55+
  (exists set
56-
exactly-n-elements(0,paper) <->
56+
     ~(exists ele1. member(ele1,set)))
57-
  (exists paper
57+
58-
     ~(exists word1. written-on(word1,paper)))
58+
max-elements(1,set) <->
59
 exactly-n-elements(0,set) v exactly-n-elements(1,set)
60-
max-elements(1,paper) <->
60+
61-
 exactly-n-elements(0,paper) v exactly-n-elements(1,paper)
61+
containsAtLeastOneUnique(set1,set2) <->
62
  (exists ele. (member(ele,set1) -> ~member(ele,set2)))
63-
containsAtLeastOneUnique(paper1,paper2) <->
63+
64-
  (exists word. (written-on(word,paper1) -> ~written-on(word,paper2)))
64+
disjoint(set1,set2) <->
65
  ~(exists ele. (member(ele,set1) & member(ele,set2)))
66-
disjoint(paper1,paper2) <->
66+
67-
  ~(exists word. (written-on(word,paper1) & written-on(word,paper2)))
67+
subset(set1,set2) <-> 
68
    (forall ele.
69-
subset(paper1,paper2) <-> 
69+
      member(ele,set1) -> member(ele,set2) )
70-
    (forall word.
70+
71-
      written-on(word,paper1) -> written-on(word,paper2) )
71+
union(set1,set2,set) <->
72
 (forall ele.
73-
union(paper1,paper2,paper) <->
73+
   (member(ele,set) <-> 
74-
 (forall word.
74+
       (member(ele,set1) v member(ele,set2))))
75-
   (written-on(word,paper) <-> 
75+
76-
       (written-on(word,paper1) v written-on(word,paper2))))
76+
union(set1,set2,set) <->
77
  (exists scratchpad. 
78-
union(paper1,paper2,paper) <->
78+
      union(set1,set2,scratchpad)
79
     & ~containsAtLeastOneUnique(set,scratchpad))
80-
      union(paper1,paper2,scratchpad)
80+
81-
     & ~containsAtLeastOneUnique(paper,scratchpad))
81+
82
union-disjoint(set1,set2,set) <-> 
83
   (   union(set1,set2,set) 
84-
union-disjoint(paper1,paper2,paper) <-> 
84+
     & disjoint(set1,set2))
85-
   (   union(paper1,paper2,paper) 
85+
86-
     & disjoint(paper1,paper2))
86+
87
min-elements(4,set) <-> 
88
  (exists set1 set2.
89-
min-elements(4,paper) <-> 
89+
     min-elements(2,set1) 
90-
  (exists paper1 paper2.
90+
   & min-elements(2,set2)
91-
     min-elements(2,paper1) 
91+
   & union-disjoint(set1,set2))
92-
   & min-elements(2,paper2)
92+
93-
   & union-disjoint(paper1,paper2))
93+
min-elements(N,set) <-> 
94
  (exists set1 set2.
95-
min-elements(N,paper) <-> 
95+
     min-elements(1,set1) 
96-
  (exists paper1 paper2.
96+
   & min-elements(M,set2)
97-
     min-elements(1,paper1) 
97+
   & non-empty(set2)
98-
   & min-elements(M,paper2)
98+
   & union-disjoint(set1,set2)
99-
   & legal-pad(paper2)
99+
100-
   & union-disjoint(paper1,paper2)
100+
101
102
max-elements(N,set) <-> 
103
  (exists set1 set2.
104-
max-elements(N,paper) <-> 
104+
     max-elements(1,set1) 
105-
  (exists paper1 paper2.
105+
   & max-elements(M,set2)
106-
     max-elements(1,paper1) 
106+
   & union-disjoint(set1,set2)
107-
   & max-elements(M,paper2)
107+
108-
   & legal-pad(paper2)
108+
109-
   & union-disjoint(paper1,paper2)
109+
110
equal_sets_v2(set1,set2) <->
111
   ( ~containsAtLeastOneUnique(set1,set2)
112
     & ~containsAtLeastOneUnique(set2,set1))
113-
equal_papers_v2(paper1,paper2) <->
113+
114-
   ( ~containsAtLeastOneUnique(paper1,paper2)
114+
equal_sets_v1(set1,set2) <->
115-
     & ~containsAtLeastOneUnique(paper2,paper1)
115+
 ( non-empty(set1)
116-
     & legal-pad(paper1)
116+
   & (forall ele. 
117-
     & legal-pad(paper2))
117+
      (member(ele,set1) <-> member(ele,set2))))