Fleet  0.0.9
Inference in the LOT
DSL.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace DSL {
4 
5  // we define these functions so that they can be used in definitions and in the grammar
6  const auto card_gt = +[](Set x, Set y) -> bool { return x.size() > y.size(); };
7  const auto card_eq = +[](Set x, Set y) -> bool { return x.size() == y.size(); };
8  const auto empty = +[](Set x) -> bool { return x.size() == 0; };
9 
10  // some "generic" sets
11  const auto singleton = +[](Set x) -> bool { return x.size() == 1; };
12  const auto doubleton = +[](Set x) -> bool { return x.size() == 2; };
13  const auto tripleton = +[](Set x) -> bool { return x.size() == 3; };
14 
15  const auto eq = +[](Set x, Set y) -> bool { return x==y; };
16 
17  const auto presup = +[](bool x, bool y) -> TruthValue {
18  if(x) return (y ? TruthValue::True : TruthValue::False);
19  else return TruthValue::Undefined;
20  };
21 
22  const auto context = +[](Utterance u) -> Set { return u.context; };
23  const auto shape = +[](Utterance u) -> Set { return u.shape; };
24  const auto color = +[](Utterance u) -> Set { return u.color; };
25 
26  const auto emptyset = +[]() -> Set { return Set(); };
27 
28  const auto subset = +[](Set x, Set y) -> bool {
29  return std::includes(y.begin(), y.end(), x.begin(), x.end()); // x \subset y
30  };
31 
32  const auto intersection = +[](Set x, Set y) -> Set {
33  Set out;
34  std::set_intersection(x.begin(), x.end(), y.begin(), y.end(), std::inserter(out, out.begin()));
35  return out;
36  };
37 
38  const auto myunion = +[](Set x, Set y) -> Set {
39  Set out;
40  std::set_union(x.begin(), x.end(), y.begin(), y.end(), std::inserter(out, out.begin()));
41  return out;
42  };
43 
44  const auto complement = +[](Set x, Utterance u) -> Set {
45  Set out;
46  std::set_difference(u.context.begin(), u.context.end(), x.begin(), x.end(), std::inserter(out, out.begin()));
47  return out;
48  };
49 
50  const auto difference = +[](Set x, Set y) -> Set {
51  Set out;
52  std::set_difference(x.begin(), x.end(), y.begin(), y.end(), std::inserter(out, out.begin()));
53  return out;
54  };
55 
56  const auto filter_color = +[](MyColor c, Set x) -> Set {
57  Set out;
58  for(auto& v : x) {
59  if(v.get<MyColor>() == c)
60  out.insert(v);
61  }
62  return out;
63  };
64 
65  const auto filter_shape = +[](MyShape s, Set x) -> Set {
66  Set out;
67  for(auto& v : x) {
68  if(v.get<MyShape>() == s)
69  out.insert(v);
70  }
71  return out;
72  };
73 }
const auto tripleton
Definition: DSL.h:13
const auto context
Definition: DSL.h:22
MyColor
Definition: Main.cpp:30
const auto card_gt
Definition: DSL.h:6
const auto subset
Definition: DSL.h:28
MyShape
Definition: Main.cpp:31
const auto myunion
Definition: DSL.h:38
const auto presup
Definition: DSL.h:17
const auto color
Definition: DSL.h:24
TruthValue
Definition: Main.cpp:32
const auto card_eq
Definition: DSL.h:7
const auto complement
Definition: DSL.h:44
const auto shape
Definition: DSL.h:23
const auto difference
Definition: DSL.h:50
const auto intersection
Definition: DSL.h:32
Definition: Main.cpp:40
const auto filter_color
Definition: DSL.h:56
Definition: DSL.h:3
const auto empty
Definition: DSL.h:8
const auto emptyset
Definition: DSL.h:26
std::multiset< MyObject > Set
Definition: Main.cpp:38
const auto doubleton
Definition: DSL.h:12
const auto filter_shape
Definition: DSL.h:65
const auto eq
Definition: DSL.h:15
const auto singleton
Definition: DSL.h:11