;; Properties
(defun exists (object)
  "The object is not unexistent."
  (list '∃ object))

(defun property (element property)
  "Evaluates a given property of an object."
  (list element "." property))

(defun capacity (element capacity)
  "Evaluates a given capacity (skill) of an element."
  (list element "||" capacity))

(defun quantity (elements)
  "Evaluates the quantity of the results of an operator."
  (list 'count elements))

(defun pertenence-to-group (element group)
  "Evaluates the pertenence of the element to a group."
  (list element "∈" group))

(defun (setf pertenence-to-group) (result object value)
  'todo=create-virtual-node)

(defun during (time events)
  "Evaluates the events during some condition."
  (list 'while "(" time ")" events))

(defun is-equal (pred1 pred2)
  "Evaluetes the equality of two predicates."
  (list pred1 "=" pred2))

(defun verb (verb-name subject)
  "Applies a vert to a subject."
  (list verb-name (list subject)))

;; Algebra
(defun product (times element)
  (list 'times times element))

;; Time
(defun time-frame (time value)
  "Evaluates a value during a time-frame."
  (list 'time time '\, value))

;; Evaluation
(defun some-element-which-complies-with (var condition)
  "Evaluates if some element complies with a condition."
  (list 'some var '\, condition))

(defun all-element-complies-with (var condition)
  "Evaluates if some every complies with a condition."
  (list 'all var '\, condition))

(defun q-and (pred1 pred2)
  "Evaluates the intersection of two predicates."
  (list 'and pred1 pred2))

(defun q-or (pred1 pred2)
  "Evaluates the union of two predicates."
  (list 'or pred1 pred2))

(defun q-not (pred)
  "Evaluates the negation of a predicate."
  (list 'not pred))

;;;; Composed
(defun exists-property-with-value (object value)
  "Evaluates the existence of a property with a given value in the object."
  (exists
   (some-element-which-complies-with
    'P
    (is-equal value
              (property object 'P)))))

(defun (setf exists-property-with-value) (result object value)
  'todo=create-virtual-node)


(defun element-of-group-has-property (element group prop)
  "Evaluates the existance of a property in the object, given the pertenence to a group."
  (q-and
   (pertenence-to-group element group)
   (exists (property element prop))))

(defun all-element-of-group-complies-with (element group condition)
  "Evaluates the compliance of a given condition given the pertenence to a group."
  (all-element-complies-with
   element
   (q-or
    (q-not (pertenence-to-group element group))
    condition)))


(defun implies (a b)
  (q-or (q-not a)
        b))