diff --git a/docs/calculus-module/1-cm.html b/docs/calculus-module/1-cm.html index 586d3b785..a9ab7ef6e 100644 --- a/docs/calculus-module/1-cm.html +++ b/docs/calculus-module/1-cm.html @@ -96,14 +96,14 @@ which use this module:
 COMPILE_WRITER(pcalc_prop *, Propositions::log)
-COMPILE_WRITER(pcalc_prop *, Atoms::log)
+COMPILE_WRITER(pcalc_prop *, Atoms::log)
 COMPILE_WRITER(pcalc_term *, Terms::log)
 COMPILE_WRITER(binary_predicate *, BinaryPredicates::log)
 COMPILE_WRITER(unary_predicate *, UnaryPredicates::log)
 
 void CalculusModule::start(void) {
     REGISTER_WRITER('D', Propositions::log);
-    REGISTER_WRITER('o', Atoms::log);
+    REGISTER_WRITER('o', Atoms::log);
     REGISTER_WRITER('0', Terms::log);
     REGISTER_WRITER('2', BinaryPredicates::log);
     REGISTER_WRITER('r', UnaryPredicates::log);
diff --git a/docs/calculus-module/2-bp.html b/docs/calculus-module/2-bp.html
index 7d4be83dd..c618ff271 100644
--- a/docs/calculus-module/2-bp.html
+++ b/docs/calculus-module/2-bp.html
@@ -825,7 +825,7 @@ so the fact that it runs relatively slowly does not matter.
 

§33.

-text_stream *BinaryPredicates::get_log_name(binary_predicate *bp) {
+text_stream *BinaryPredicates::get_log_name(binary_predicate *bp) {
     return bp->debugging_log_name;
 }
 
diff --git a/docs/calculus-module/2-tcp.html b/docs/calculus-module/2-tcp.html index 9f4d2cfb1..b00ebd877 100644 --- a/docs/calculus-module/2-tcp.html +++ b/docs/calculus-module/2-tcp.html @@ -75,7 +75,12 @@ exist.
 up_family *calling_up_family = NULL;
-up_family *creation_up_family = NULL;
+up_family *is_a_var_up_family = NULL;
+up_family *is_a_const_up_family = NULL;
+up_family *is_a_kind_up_family = NULL;
+
+unary_predicate *is_a_var_up = NULL;
+unary_predicate *is_a_const_up = NULL;
 

§2. Family. This is a minimal representation only: Inform adds other methods to the equality family to handle its typechecking and so on. @@ -84,8 +89,19 @@ family to handle its typechecking and so on.

 void Calculus::Creation::start(void) {
     calling_up_family = UnaryPredicateFamilies::new();
-    creation_up_family = UnaryPredicateFamilies::new();
-    METHOD_ADD(creation_up_family, STOCK_UPF_MTID, Calculus::Creation::stock_creation);
+    is_a_var_up_family = UnaryPredicateFamilies::new();
+    METHOD_ADD(is_a_var_up_family, STOCK_UPF_MTID, Calculus::Creation::stock_is_a_var);
+    METHOD_ADD(is_a_var_up_family, LOG_UPF_MTID, Calculus::Creation::log_is_a_var);
+    is_a_const_up_family = UnaryPredicateFamilies::new();
+    METHOD_ADD(is_a_const_up_family, STOCK_UPF_MTID, Calculus::Creation::stock_is_a_const);
+    METHOD_ADD(is_a_const_up_family, LOG_UPF_MTID, Calculus::Creation::log_is_a_const);
+    is_a_kind_up_family = UnaryPredicateFamilies::new();
+    METHOD_ADD(is_a_kind_up_family, LOG_UPF_MTID, Calculus::Creation::log_is_a_kind);
+    #ifdef CORE_MODULE
+    METHOD_ADD(is_a_var_up_family, TYPECHECK_UPF_MTID, Calculus::Creation::typecheck_is_a_var);
+    METHOD_ADD(is_a_const_up_family, TYPECHECK_UPF_MTID, Calculus::Creation::typecheck_is_a_const);
+    METHOD_ADD(is_a_kind_up_family, TYPECHECK_UPF_MTID, Calculus::Creation::typecheck_is_a_kind);
+    #endif
 }
 

§3. Initial stock. This relation is hard-wired in, and it is made in a slightly special way @@ -93,11 +109,62 @@ since (alone among binary predicates) it has no distinct reversal.

-void Calculus::Creation::stock_creation(up_family *self, int n) {
+void Calculus::Creation::stock_is_a_var(up_family *self, int n) {
     if (n == 1) {
-        ;  make isakind, etc., here
+        is_a_var_up = UnaryPredicates::blank(is_a_var_up_family);
     }
 }
+
+void Calculus::Creation::stock_is_a_const(up_family *self, int n) {
+    if (n == 1) {
+        is_a_const_up = UnaryPredicates::blank(is_a_const_up_family);
+    }
+}
+
+pcalc_prop *Calculus::Creation::is_a_var_up(pcalc_term t) {
+    return Atoms::unary_PREDICATE_new(is_a_var_up, t);
+}
+
+pcalc_prop *Calculus::Creation::is_a_const_up(pcalc_term t) {
+    return Atoms::unary_PREDICATE_new(is_a_const_up, t);
+}
+
+pcalc_prop *Calculus::Creation::is_a_kind_up(pcalc_term t, kind *K) {
+    unary_predicate *up = UnaryPredicates::blank(is_a_kind_up_family);
+    up->assert_kind = K;
+    return Atoms::unary_PREDICATE_new(up, t);
+}
+
+#ifdef CORE_MODULE
+int Calculus::Creation::typecheck_is_a_var(up_family *self, unary_predicate *up,
+    pcalc_prop *prop, variable_type_assignment *vta, tc_problem_kit *tck) {
+    return ALWAYS_MATCH;
+}
+int Calculus::Creation::typecheck_is_a_const(up_family *self, unary_predicate *up,
+    pcalc_prop *prop, variable_type_assignment *vta, tc_problem_kit *tck) {
+    return ALWAYS_MATCH;
+}
+int Calculus::Creation::typecheck_is_a_kind(up_family *self, unary_predicate *up,
+    pcalc_prop *prop, variable_type_assignment *vta, tc_problem_kit *tck) {
+    kind *actually_find = Propositions::Checker::kind_of_term(&(prop->terms[0]), vta, tck);
+    if (Kinds::compatible(actually_find, K_object) == NEVER_MATCH)
+        internal_error("is_a_kind predicate misapplied");
+    return ALWAYS_MATCH;
+}
+#endif
+
+void Calculus::Creation::log_is_a_var(up_family *self, OUTPUT_STREAM, unary_predicate *up) {
+    WRITE("is-a-var");
+}
+
+void Calculus::Creation::log_is_a_const(up_family *self, OUTPUT_STREAM, unary_predicate *up) {
+    WRITE("is-a-const");
+}
+
+void Calculus::Creation::log_is_a_kind(up_family *self, OUTPUT_STREAM, unary_predicate *up) {
+    WRITE("is-a-kind");
+    if (up->assert_kind) WRITE("=%u", up->assert_kind);
+}
 
-int Atoms::group(int element) {
+int Atoms::group(int element) {
     if (element <= 0) return 0;
     if (element < QUANTIFIERS_GROUP) return QUANTIFIERS_GROUP;
     if (element < PREDICATES_GROUP) return PREDICATES_GROUP;
@@ -164,7 +161,7 @@ like this, or else returns the opposite number to any element code which does.
 

-pcalc_prop *Atoms::new(int element) {
+pcalc_prop *Atoms::new(int element) {
     pcalc_prop *prop = CREATE(pcalc_prop);
     prop->next = NULL;
     prop->element = element;
@@ -291,30 +288,7 @@ special cases.
     return prop;
 }
 
-

§10. And the ISAKIND, ISAVAR and ISACONST creation predicates: -

- -
-pcalc_prop *Atoms::ISAKIND_new(pcalc_term pt, kind *K) {
-    pcalc_prop *prop = Atoms::new(ISAKIND_ATOM);
-    prop->terms[prop->arity++] = pt;
-    prop->assert_kind = K;
-    return prop;
-}
-
-pcalc_prop *Atoms::ISAVAR_new(pcalc_term pt) {
-    pcalc_prop *prop = Atoms::new(ISAVAR_ATOM);
-    prop->terms[prop->arity++] = pt;
-    return prop;
-}
-
-pcalc_prop *Atoms::ISACONST_new(pcalc_term pt) {
-    pcalc_prop *prop = Atoms::new(ISACONST_ATOM);
-    prop->terms[prop->arity++] = pt;
-    return prop;
-}
-
-

§11. CALLED atoms are interesting because they exist only for their side-effects: +

§10. CALLED atoms are interesting because they exist only for their side-effects: they have no effect at all on the logical status of a proposition (well, except that they should not be applied to free variables referred to nowhere else). They can therefore be added or removed freely. In the phrase @@ -334,7 +308,7 @@ will be called.

-int Atoms::is_CALLED(pcalc_prop *prop) {
+int Atoms::is_CALLED(pcalc_prop *prop) {
     if (prop->element == CALLED_ATOM) return TRUE;
     return FALSE;
 }
@@ -347,11 +321,11 @@ will be called.
     return prop;
 }
 
-wording Atoms::CALLED_get_name(pcalc_prop *prop) {
+wording Atoms::CALLED_get_name(pcalc_prop *prop) {
     return prop->calling_name;
 }
 
-

§12. Now for a KIND atom. At first sight, it looks odd that a unary +

§11. Now for a KIND atom. At first sight, it looks odd that a unary predicate for a kind is represented differently from other predicates. Isn't it a unary predicate just like any other? Well: it is, but has the special property that its truth does not change over time. If a value v @@ -376,7 +350,7 @@ ways. return NULL; }

-

§13. Composited KIND atoms are special in that they represent composites +

§12. Composited KIND atoms are special in that they represent composites of quantifiers with common nouns — for example, "everyone" is a composite meaning "every person".

@@ -400,7 +374,7 @@ meaning "every person". if (prop) prop->composited = state; } -

§14. Unarticled kinds are those which were introduced without an article, in +

§13. Unarticled kinds are those which were introduced without an article, in the linguistic sense.

@@ -414,34 +388,37 @@ the linguistic sense. if (prop) prop->unarticled = state; } -

§15. That just leaves the general sort of unary predicate. In principle we ought +

§14. That just leaves the general sort of unary predicate. In principle we ought to be able to create \(U(t)\) for any term \(t\), but in practice we only ever need \(t=x\), that is, variable 0.

-pcalc_prop *Atoms::from_adjective(adjective *aph, int negated, pcalc_term t) {
+pcalc_prop *Atoms::unary_PREDICATE_new(unary_predicate *up, pcalc_term t) {
     pcalc_prop *prop = Atoms::new(PREDICATE_ATOM);
     prop->arity = 1;
     prop->terms[0] = t;
-    prop->predicate = STORE_POINTER_unary_predicate(
-        UnaryPredicates::new(aph, (negated)?FALSE:TRUE));
+    prop->predicate = STORE_POINTER_unary_predicate(up);
     return prop;
 }
 
-pcalc_prop *Atoms::from_adjective_on_x(adjective *aph, int negated) {
-    return Atoms::from_adjective(aph, negated, Terms::new_variable(0));
+pcalc_prop *Atoms::from_adjective(adjective *aph, int negated, pcalc_term t) {
+    return Atoms::unary_PREDICATE_new(UnaryPredicates::new(aph, (negated)?FALSE:TRUE), t);
 }
 
-unary_predicate *Atoms::to_adjectival_usage(pcalc_prop *prop) {
+pcalc_prop *Atoms::from_adjective_on_x(adjective *aph, int negated) {
+    return Atoms::from_adjective(aph, negated, Terms::new_variable(0));
+}
+
+unary_predicate *Atoms::to_adjectival_usage(pcalc_prop *prop) {
     return RETRIEVE_POINTER_unary_predicate(prop->predicate);
 }
 
-

§16. And binary predicates are pretty well the same: +

§15. And binary predicates are pretty well the same:

-pcalc_prop *Atoms::binary_PREDICATE_new(binary_predicate *bp,
+pcalc_prop *Atoms::binary_PREDICATE_new(binary_predicate *bp,
     pcalc_term pt1, pcalc_term pt2) {
     pcalc_prop *prop = Atoms::new(PREDICATE_ATOM);
     prop->arity = 2;
@@ -457,35 +434,35 @@ need \(t=x\), that is, variable 0.
     return RETRIEVE_POINTER_binary_predicate(prop->predicate);
 }
 
-int Atoms::is_equality_predicate(pcalc_prop *prop) {
-    binary_predicate *bp = Atoms::is_binary_predicate(prop);
+int Atoms::is_equality_predicate(pcalc_prop *prop) {
+    binary_predicate *bp = Atoms::is_binary_predicate(prop);
     if (bp == R_equality) return TRUE;
     return FALSE;
 }
 
-

§17. Given \(C\), return the proposition (x == C): +

§16. Given \(C\), return the proposition (x == C):

 pcalc_prop *Atoms::prop_x_is_constant(parse_node *C) {
-    return Atoms::binary_PREDICATE_new(R_equality,
+    return Atoms::binary_PREDICATE_new(R_equality,
         Terms::new_variable(0), Terms::new_constant(C));
 }
 
-

§18. And conversely: +

§17. And conversely:

 pcalc_term *Atoms::is_x_equals(pcalc_prop *prop) {
-    if (Atoms::is_equality_predicate(prop) == FALSE) return NULL;
+    if (Atoms::is_equality_predicate(prop) == FALSE) return NULL;
     if (prop->terms[0].variable != 0) return NULL;
     return &(prop->terms[1]);
 }
 
-

§19. Validating atoms.

+

§18. Validating atoms.

-char *Atoms::validate(pcalc_prop *prop) {
+char *Atoms::validate(pcalc_prop *prop) {
     int group;
     if (prop == NULL) return NULL;
     group = Atoms::group(prop->element);
@@ -506,18 +483,18 @@ need \(t=x\), that is, variable 0.
     return NULL;
 }
 
-

§20. Writing to text. Logging atomic propositions divides into cases: +

§19. Writing to text. Logging atomic propositions divides into cases:

-void Atoms::log(pcalc_prop *prop) {
-    Atoms::write(DL, prop);
+void Atoms::log(pcalc_prop *prop) {
+    Atoms::write(DL, prop);
 }
-void Atoms::write(text_stream *OUT, pcalc_prop *prop) {
+void Atoms::write(text_stream *OUT, pcalc_prop *prop) {
     if (prop == NULL) { WRITE("<null-atom>"); return; }
-    Use a special notation for equality20.1;
-    if (Atoms::is_CALLED(prop)) {
-        wording W = Atoms::CALLED_get_name(prop);
+    Use a special notation for equality19.1;
+    if (Atoms::is_CALLED(prop)) {
+        wording W = Atoms::CALLED_get_name(prop);
         WRITE("called='%W'", W);
         if (prop->assert_kind) {
             WRITE("(");
@@ -528,15 +505,15 @@ need \(t=x\), that is, variable 0.
     switch(prop->element) {
         case PREDICATE_ATOM:
             switch(prop->arity) {
-                case 1: Log some suitable textual name for this unary predicate20.2; break;
-                case 2: Log some suitable textual name for this binary predicate20.3; break;
+                case 1: Log some suitable textual name for this unary predicate19.2; break;
+                case 2: Log some suitable textual name for this binary predicate19.3; break;
                 default: WRITE("?exotic-predicate-arity=%d?", prop->arity); break;
             }
             break;
         case QUANTIFIER_ATOM: {
             quantifier *quant = prop->quant;
             Quantifiers::log(OUT, quant, prop->quantification_parameter);
-            WRITE(" "); Log a comma-separated list of terms for this atomic proposition20.4;
+            WRITE(" "); Log a comma-separated list of terms for this atomic proposition19.4;
             return;
         }
         case KIND_ATOM:
@@ -545,9 +522,6 @@ need \(t=x\), that is, variable 0.
             if ((Streams::I6_escapes_enabled(DL) == FALSE) && (prop->composited)) WRITE("_c");
             if ((Streams::I6_escapes_enabled(DL) == FALSE) && (prop->unarticled)) WRITE("_u");
             break;
-        case ISAKIND_ATOM: WRITE("is-a-kind"); break;
-        case ISAVAR_ATOM: WRITE("is-a-var"); break;
-        case ISACONST_ATOM: WRITE("is-a-const"); break;
         case EVERYWHERE_ATOM: WRITE("everywhere"); break;
         case NOWHERE_ATOM: WRITE("nowhere"); break;
         case HERE_ATOM: WRITE("here"); break;
@@ -559,12 +533,12 @@ need \(t=x\), that is, variable 0.
     }
     if (prop->arity > 0) {
         WRITE("(");
-        Log a comma-separated list of terms for this atomic proposition20.4;
+        Log a comma-separated list of terms for this atomic proposition19.4;
         WRITE(")");
     }
 }
 
-

§20.1. Use a special notation for equality20.1 = +

§19.1. Use a special notation for equality19.1 =

@@ -578,24 +552,24 @@ need \(t=x\), that is, variable 0.
         return;
     }
 
- -

§20.2. Log some suitable textual name for this unary predicate20.2 = +

+

§19.2. Log some suitable textual name for this unary predicate19.2 =

     unary_predicate *tr = RETRIEVE_POINTER_unary_predicate(prop->predicate);
     UnaryPredicateFamilies::log(OUT, tr);
 
- -

§20.3. Log some suitable textual name for this binary predicate20.3 = +

+

§19.3. Log some suitable textual name for this binary predicate19.3 =

     binary_predicate *bp = RETRIEVE_POINTER_binary_predicate(prop->predicate);
     if (bp == NULL) WRITE("?bad-bp?"); else WRITE("%S", BinaryPredicates::get_log_name(bp));
 
- -

§20.4. Log a comma-separated list of terms for this atomic proposition20.4 = +

+

§19.4. Log a comma-separated list of terms for this atomic proposition19.4 =

@@ -604,7 +578,7 @@ need \(t=x\), that is, variable 0.
         Terms::write(OUT, &(prop->terms[t]));
     }
 
- + diff --git a/docs/calculus-module/3-prp.html b/docs/calculus-module/3-prp.html index 88c64b190..5e77d239e 100644 --- a/docs/calculus-module/3-prp.html +++ b/docs/calculus-module/3-prp.html @@ -242,7 +242,7 @@ logged as just << >& char *bridge = Propositions::debugging_log_text_between(p_prev, p); if (bridge[0]) WRITE("%s ", bridge); if (log_addresses) WRITE("%08x=", (unsigned int) p); - Atoms::write(OUT, p); + Atoms::write(OUT, p); WRITE(" "); } WRITE(">>"); @@ -301,7 +301,7 @@ could EVERYWHERE(x)

§10. The following tests only (ii), validity. calculus-test is unable to make -atoms which fail to pass Atoms::validate, nor can it make some of the +atoms which fail to pass Atoms::validate, nor can it make some of the misconstructions tested for below, but numerous other defects can be tested:

@@ -334,7 +334,7 @@ misconstructions tested for below, but numerous other defects can be tested: int groups_stack[MAX_PROPOSITION_GROUP_NESTING], group_sp = 0; TRAVERSE_PROPOSITION(p, prop) { (1) each individual atom has to be properly built: - char *v_err = Atoms::validate(p); + char *v_err = Atoms::validate(p); if (v_err) { WRITE_TO(err, "atom error: %s", err); return FALSE; } (2) every open bracket must be matched by a close bracket of the same kind: if (Atoms::group(p->element) == OPEN_OPERATORS_GROUP) { @@ -401,7 +401,7 @@ value to x. Exa if (p->element == DOMAIN_OPEN_ATOM) return TRUE; if (p->element == DOMAIN_CLOSE_ATOM) return TRUE; if ((p->element == PREDICATE_ATOM) && (p->arity == 2)) { - if (Atoms::is_equality_predicate(p) == FALSE) return TRUE; + if (Atoms::is_equality_predicate(p) == FALSE) return TRUE; if (!(((p->terms[0].variable == 0) && (p->terms[1].constant)) || ((p->terms[1].variable == 0) && (p->terms[0].constant)))) return TRUE; } @@ -681,7 +681,7 @@ a given arity, or both: return NULL; } -pcalc_prop *Propositions::prop_seek_up_family(pcalc_prop *prop, up_family *f) { +pcalc_prop *Propositions::prop_seek_up_family(pcalc_prop *prop, up_family *f) { TRAVERSE_VARIABLE(p); TRAVERSE_PROPOSITION(p, prop) if ((p->element == PREDICATE_ATOM) && (p->arity == 1)) { @@ -720,7 +720,7 @@ a given arity, or both: int Propositions::contains_callings(pcalc_prop *prop) { for (pcalc_prop *p = prop; p; p = p->next) - if (Atoms::is_CALLED(p)) + if (Atoms::is_CALLED(p)) return TRUE; return FALSE; } @@ -732,9 +732,12 @@ expense of typechecking the proposition:
 kind *Propositions::describes_kind(pcalc_prop *prop) {
     pcalc_prop *p = prop;
-    while ((p = Propositions::prop_seek_atom(p, ISAKIND_ATOM, 1)) != NULL) {
+    while ((p = Propositions::prop_seek_up_family(p, is_a_kind_up_family)) != NULL) {
         if ((Terms::variable_underlying(&(p->terms[0])) == 0) &&
-            (Kinds::eq(p->assert_kind, K_value))) return p->assert_kind;
+            (Kinds::eq(p->assert_kind, K_value))) {
+            unary_predicate *up = RETRIEVE_POINTER_unary_predicate(p->predicate);
+            return up->assert_kind;
+        }
         p = p->next;
     }
     p = prop;
@@ -761,7 +764,7 @@ expense of typechecking the proposition:
             case DOMAIN_CLOSE_ATOM: bl--; break;
             default:
                 if (bl == 0) {
-                    if (Atoms::is_equality_predicate(p)) {
+                    if (Atoms::is_equality_predicate(p)) {
                         if ((p->terms[0].variable == 0) && (p->terms[1].constant))
                             return p->terms[1].constant;
                         if ((p->terms[1].variable == 0) && (p->terms[0].constant))
@@ -850,7 +853,7 @@ following are useful for looping through them:
     prop = Propositions::prop_seek_up_family(prop, adjectival_up_family);
     if (ppp) *ppp = prop;
     if (prop == NULL) return NULL;
-    return Atoms::to_adjectival_usage(prop);
+    return Atoms::to_adjectival_usage(prop);
 }
 
 unary_predicate *Propositions::next_unary_predicate(pcalc_prop **ppp) {
@@ -858,7 +861,7 @@ following are useful for looping through them:
     pcalc_prop *prop = Propositions::prop_seek_up_family((*ppp)->next, adjectival_up_family);
     *ppp = prop;
     if (prop == NULL) return NULL;
-    return Atoms::to_adjectival_usage(prop);
+    return Atoms::to_adjectival_usage(prop);
 }
 

§31. Bracketed groups. The following routine tests whether the entire proposition is a single diff --git a/docs/calculus-module/3-trm.html b/docs/calculus-module/3-trm.html index 1463e7e0a..8c077f436 100644 --- a/docs/calculus-module/3-trm.html +++ b/docs/calculus-module/3-trm.html @@ -165,14 +165,14 @@ field is

§4. Creating new terms.

-pcalc_term Terms::new_variable(int v) {
+pcalc_term Terms::new_variable(int v) {
     pcalc_term pt; Make new blank term structure pt4.1;
     if ((v < 0) || (v >= 26)) internal_error("bad variable term created");
     pt.variable = v;
     return pt;
 }
 
-pcalc_term Terms::new_constant(parse_node *c) {
+pcalc_term Terms::new_constant(parse_node *c) {
     pcalc_term pt; Make new blank term structure pt4.1;
     pt.constant = c;
     return pt;
@@ -357,7 +357,7 @@ concisely and without fuss.
 void Terms::log(pcalc_term *pt) {
     Terms::write(DL, pt);
 }
-void Terms::write(text_stream *OUT, pcalc_term *pt) {
+void Terms::write(text_stream *OUT, pcalc_term *pt) {
     if (pt == NULL) {
         WRITE("<null-term>");
     } else if (pt->constant) {
diff --git a/docs/calculus-module/P-wtmd.html b/docs/calculus-module/P-wtmd.html
index a8c41b7ff..3dfa21199 100644
--- a/docs/calculus-module/P-wtmd.html
+++ b/docs/calculus-module/P-wtmd.html
@@ -294,14 +294,13 @@ calls.
 

2. Unary predicate atoms are made using:

-
  • Atoms::from_adjective, or -
  • Atoms::KIND_new, or -
  • Atoms::CALLED_new, or -
  • Atoms::new for the six oddball unaries, -supplying atom types ISAKIND_ATOM, ISAVAR_ATOM, ISACONST_ATOM, + -

    Binary predicate atoms are made using Atoms::binary_PREDICATE_new. +

    Binary predicate atoms are made using Atoms::binary_PREDICATE_new.

    3. Propositions are then built up from atoms or other propositions8 by calling: diff --git a/docs/calculus-test/1-dcl.html b/docs/calculus-test/1-dcl.html index 9efc3c481..1b9860094 100644 --- a/docs/calculus-test/1-dcl.html +++ b/docs/calculus-test/1-dcl.html @@ -222,9 +222,9 @@ sentence. In effect, this is a read-evaluate-print loop. everywhere ( <term> ) | ==> { -, Atoms::EVERYWHERE_new(*((pcalc_term *) RP[1])) } nowhere ( <term> ) | ==> { -, Atoms::NOWHERE_new(*((pcalc_term *) RP[1])) } here ( <term> ) | ==> { -, Atoms::HERE_new(*((pcalc_term *) RP[1])) } - is-a-kind ( <term> ) | ==> { -, Atoms::ISAKIND_new(*((pcalc_term *) RP[1]), NULL) } - is-a-var ( <term> ) | ==> { -, Atoms::ISAVAR_new(*((pcalc_term *) RP[1])) } - is-a-const ( <term> ) | ==> { -, Atoms::ISACONST_new(*((pcalc_term *) RP[1])) } + is-a-kind ( <term> ) | ==> { -, Calculus::Creation::is_a_kind_up(*((pcalc_term *) RP[1]), NULL) } + is-a-var ( <term> ) | ==> { -, Calculus::Creation::is_a_var_up(*((pcalc_term *) RP[1])) } + is-a-const ( <term> ) | ==> { -, Calculus::Creation::is_a_const_up(*((pcalc_term *) RP[1])) } not< | ==> { -, Atoms::new(NEGATION_OPEN_ATOM) } not> | ==> { -, Atoms::new(NEGATION_CLOSE_ATOM) } in< | ==> { -, Atoms::new(DOMAIN_OPEN_ATOM) } diff --git a/docs/core-module/11-tc.html b/docs/core-module/11-tc.html index 07879a700..1f42db2e9 100644 --- a/docs/core-module/11-tc.html +++ b/docs/core-module/11-tc.html @@ -81,15 +81,15 @@ their existence.

     pcalc_prop *Propositions::Abstract::to_make_a_kind(kind *K) {
    -    return Atoms::ISAKIND_new(Terms::new_variable(0), K);
    +    return Calculus::Creation::is_a_kind_up(Terms::new_variable(0), K);
     }
     
     pcalc_prop *Propositions::Abstract::to_make_a_var(void) {
    -    return Atoms::ISAVAR_new(Terms::new_variable(0));
    +    return Calculus::Creation::is_a_var_up(Terms::new_variable(0));
     }
     
     pcalc_prop *Propositions::Abstract::to_make_a_const(void) {
    -    return Atoms::ISACONST_new(Terms::new_variable(0));
    +    return Calculus::Creation::is_a_const_up(Terms::new_variable(0));
     }
     
     pcalc_prop *Propositions::Abstract::to_create_something(kind *K, wording W) {
    diff --git a/docs/core-module/11-tcp.html b/docs/core-module/11-tcp.html
    index 090899b75..4f5666485 100644
    --- a/docs/core-module/11-tcp.html
    +++ b/docs/core-module/11-tcp.html
    @@ -160,16 +160,14 @@ sense of the proposition by changing it, it will do so.
             if ((pl->element == PREDICATE_ATOM) && (pl->arity == 1))
                 A unary predicate is required to have an interpretation matching the kind of its term4.6;
             if (pl->element == EVERYWHERE_ATOM)
    -            An EVERYWHERE atom needs its term to be an object4.9;
    +            An EVERYWHERE atom needs its term to be an object4.8;
             if (pl->element == NOWHERE_ATOM)
    -            A NOWHERE atom needs its term to be an object4.10;
    -        if (pl->element == ISAKIND_ATOM)
    -            An ISAKIND atom needs its term to be an object4.8;
    +            A NOWHERE atom needs its term to be an object4.9;
             if (pl->element == HERE_ATOM)
    -            A HERE atom needs its term to be an object4.11;
    +            A HERE atom needs its term to be an object4.10;
         }
     
    -    if (tck->log_to_I6_text) Show the variable assignment in the debugging log4.12;
    +    if (tck->log_to_I6_text) Show the variable assignment in the debugging log4.11;
         return ALWAYS_MATCH;
     }
     
    @@ -423,16 +421,7 @@ would work instead. If it would, we make the change within the proposition. return NEVER_MATCH;
  • This code is used in §4.7 (three times).
-

§4.8. An ISAKIND atom needs its term to be an object4.8 = -

- -
-    kind *actually_find = Propositions::Checker::kind_of_term(&(pl->terms[0]), &vta, tck);
-    if (Kinds::compatible(actually_find, K_object) == NEVER_MATCH)
-        internal_error("ISAKIND atom misapplied");
-
-
  • This code is used in §4.
-

§4.9. An EVERYWHERE atom needs its term to be an object4.9 = +

§4.8. An EVERYWHERE atom needs its term to be an object4.8 =

@@ -451,7 +440,7 @@ would work instead. If it would, we make the change within the proposition.
     }
 
  • This code is used in §4.
-

§4.10. A NOWHERE atom needs its term to be an object4.10 = +

§4.9. A NOWHERE atom needs its term to be an object4.9 =

@@ -469,11 +458,11 @@ would work instead. If it would, we make the change within the proposition.
     }
 
  • This code is used in §4.
-

§4.11. It seems to be true that the A-parser never generates propositions which +

§4.10. It seems to be true that the A-parser never generates propositions which apply HERE incorrectly, but just in case:

-

A HERE atom needs its term to be an object4.11 = +

A HERE atom needs its term to be an object4.10 =

@@ -490,12 +479,12 @@ apply HERE inco
     }
 
  • This code is used in §4.
-

§4.12. Not so much for the debugging log as for the internal test, in fact, which +

§4.11. Not so much for the debugging log as for the internal test, in fact, which prints the log to an I6 string. This is the type-checking report in the case of success.

-

Show the variable assignment in the debugging log4.12 = +

Show the variable assignment in the debugging log4.11 =

@@ -517,7 +506,7 @@ which is why the routine is here and not in the Terms section.
 

-kind *Propositions::Checker::kind_of_term(pcalc_term *pt, variable_type_assignment *vta,
+kind *Propositions::Checker::kind_of_term(pcalc_term *pt, variable_type_assignment *vta,
     tc_problem_kit *tck) {
     kind *K = Propositions::Checker::kind_of_term_inner(pt, vta, tck);
     pt->term_checked_as_kind = K;
diff --git a/docs/core-module/12-ap.html b/docs/core-module/12-ap.html
index 0c39822f2..31c38ff80 100644
--- a/docs/core-module/12-ap.html
+++ b/docs/core-module/12-ap.html
@@ -451,11 +451,18 @@ interpret no indication of a kind as meaning "object".
         if ((lookahead->arity == 1) && (lookahead->terms[0].variable == v)) {
             if (Atoms::is_CALLED(lookahead)) {
                 NW = Atoms::CALLED_get_name(lookahead);
-            } else switch(lookahead->element) {
-                case KIND_ATOM: K = lookahead->assert_kind; break;
-                case ISAKIND_ATOM: is_a_kind = TRUE; K = lookahead->assert_kind; break;
-                case ISAVAR_ATOM: is_a_var = TRUE; break;
-                case ISACONST_ATOM: is_a_const = TRUE; break;
+            } else if (lookahead->element == KIND_ATOM) K = lookahead->assert_kind;
+            else if ((lookahead->element == PREDICATE_ATOM) && (lookahead->arity == 1)) {
+                unary_predicate *up = RETRIEVE_POINTER_unary_predicate(lookahead->predicate);
+                if (up->family == is_a_kind_up_family) {
+                    is_a_kind = TRUE; K = up->assert_kind;
+                }
+                if (up->family == is_a_var_up_family) {
+                    is_a_var = TRUE;
+                }
+                if (up->family == is_a_const_up_family) {
+                    is_a_const = TRUE;
+                }
             }
         }
 
diff --git a/docs/core-module/2-si.html b/docs/core-module/2-si.html index 652657b97..2acea3ad0 100644 --- a/docs/core-module/2-si.html +++ b/docs/core-module/2-si.html @@ -208,7 +208,7 @@ table we are in, yet still only cite a small part of it —

-void StandardProblems::tcp_problem(SIGIL_ARGUMENTS, tc_problem_kit *tck, char *prototype) {
+void StandardProblems::tcp_problem(SIGIL_ARGUMENTS, tc_problem_kit *tck, char *prototype) {
     if (tck->issue_error) {
         ACT_ON_SIGIL
         Problems::quote_source(1, current_sentence);
diff --git a/docs/core-module/2-sq.html b/docs/core-module/2-sq.html
index 921c109e7..952ccce7d 100644
--- a/docs/core-module/2-sq.html
+++ b/docs/core-module/2-sq.html
@@ -176,7 +176,7 @@ this as some kind of marginal will-never-happen case.
 

-void Problems::quote_kind(int t, kind *K) {
+void Problems::quote_kind(int t, kind *K) {
     if ((K == NULL) || (Kinds::eq(K, K_nil))) Problems::quote_text(t, "nothing");
     else if ((K == NULL) || (Kinds::eq(K, K_void))) Problems::quote_text(t, "nothing");
     else Problems::problem_quote(t, (void *) K, Problems::expand_kind);
diff --git a/docs/core-module/5-tc.html b/docs/core-module/5-tc.html
index 268e39002..12a18f0e2 100644
--- a/docs/core-module/5-tc.html
+++ b/docs/core-module/5-tc.html
@@ -942,6 +942,7 @@ to abbreviated forms of object names are normally allowed.
     else
         prop = Propositions::concatenate(prop, Propositions::Abstract::to_make_a_var());
     Propositions::Assert::assert_true(prop, prevailing_mood);
+    if (NonlocalVariables::get_latest() == NULL) internal_error("failed to create");
     val = Lvalues::new_actual_NONLOCAL_VARIABLE(NonlocalVariables::get_latest());
 
diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt index f05ac3a8c..595892ac8 100644 --- a/inform7/Figures/memory-diagnostics.txt +++ b/inform7/Figures/memory-diagnostics.txt @@ -1,13 +1,13 @@ -Total memory consumption was 256343K = 250 MB +Total memory consumption was 257143K = 251 MB -62.4% was used for 1330248 objects, in 273443 frames in 200 x 800K = 160000K = 156 MB: +62.5% was used for 1330259 objects, in 273454 frames in 201 x 800K = 160800K = 157 MB: 9.8% inter_tree_node_array 36 x 8192 = 294912 objects, 25953408 bytes - 5.5% text_stream_array 2567 x 100 = 256700 objects, 14457344 bytes + 5.4% text_stream_array 2567 x 100 = 256700 objects, 14457344 bytes 3.9% parse_node 129994 objects, 10399520 bytes 2.8% verb_conjugation 160 objects, 7425280 bytes 2.6% parse_node_annotation_array 431 x 500 = 215500 objects, 6909792 bytes - 2.4% inter_symbol_array 70 x 1024 = 71680 objects, 6310080 bytes + 2.3% inter_symbol_array 70 x 1024 = 71680 objects, 6310080 bytes 1.8% linked_list 8904 objects, 4986240 bytes 1.3% pcalc_prop_array 24 x 1000 = 24000 objects, 3648768 bytes 1.2% map_data 668 objects, 3168992 bytes @@ -41,6 +41,7 @@ Total memory consumption was 256343K = 250 MB ---- action_name_list_array 3 x 1000 = 3000 objects, 240096 bytes ---- binary_predicate 321 objects, 197736 bytes ---- inter_annotation_array 1 x 8192 objects, 196640 bytes + ---- unary_predicate_array 8 x 1000 = 8000 objects, 192256 bytes ---- inference 1703 objects, 177112 bytes ---- linked_list_item_array 10 x 1000 = 10000 objects, 160320 bytes ---- linguistic_stock_item 3315 objects, 159120 bytes @@ -48,7 +49,6 @@ Total memory consumption was 256343K = 250 MB ---- index_lexicon_entry 395 objects, 142200 bytes ---- nonterminal 754 objects, 138736 bytes ---- action_pattern_array 6 x 100 = 600 objects, 129792 bytes - ---- unary_predicate_array 8 x 1000 = 8000 objects, 128256 bytes ---- documentation_ref 1275 objects, 112200 bytes ---- hierarchy_location 730 objects, 105120 bytes ---- noun_usage 2401 objects, 96040 bytes @@ -93,8 +93,8 @@ Total memory consumption was 256343K = 250 MB ---- adjective_iname_holder 320 objects, 15360 bytes ---- plugin 23 objects, 13432 bytes ---- literal_text 147 objects, 12936 bytes + ---- method 250 objects, 12000 bytes ---- stopwatch_timer 148 objects, 11840 bytes - ---- method 243 objects, 11664 bytes ---- understanding_reference_array 2 x 100 = 200 objects, 11264 bytes ---- pathname 262 objects, 10480 bytes ---- adjective 137 objects, 9864 bytes @@ -129,8 +129,8 @@ Total memory consumption was 256343K = 250 MB ---- kind_constructor_instance_array 1 x 100 objects, 2432 bytes ---- kind_constructor_casting_rule_array 1 x 100 objects, 2432 bytes ---- equation_symbol 30 objects, 2400 bytes + ---- method_set 72 objects, 2304 bytes ---- semver_range 22 objects, 2288 bytes - ---- method_set 70 objects, 2240 bytes ---- use_option 29 objects, 1856 bytes ---- pronoun_usage 42 objects, 1680 bytes ---- plugin_call_array 1 x 100 objects, 1632 bytes @@ -192,30 +192,30 @@ Total memory consumption was 256343K = 250 MB ---- kit_dependency 4 objects, 192 bytes ---- plural_dictionary_entry 4 objects, 192 bytes ---- inform_project 1 object, 176 bytes - ---- pointer_allocation 2 objects, 160 bytes + ---- up_family 5 objects, 160 bytes ---- inter_architecture 4 objects, 160 bytes ---- link_instruction 4 objects, 160 bytes ---- code_generation_target 4 objects, 160 bytes + ---- pointer_allocation 2 objects, 160 bytes ---- codegen_pipeline 1 object, 128 bytes ---- element_activation 4 objects, 128 bytes ---- inbuild_nest 3 objects, 120 bytes ---- inform_kit_ittt 2 objects, 96 bytes - ---- up_family 3 objects, 96 bytes - ---- list_together_routine 2 objects, 80 bytes - ---- compile_task_data 1 object, 80 bytes ---- article 2 objects, 80 bytes + ---- compile_task_data 1 object, 80 bytes + ---- list_together_routine 2 objects, 80 bytes ---- inter_warehouse 1 object, 56 bytes ---- build_methodology 1 object, 56 bytes - ---- blorb_figure 1 object, 48 bytes - ---- HTML_file_state 1 object, 48 bytes ---- star_invention 1 object, 48 bytes + ---- HTML_file_state 1 object, 48 bytes + ---- blorb_figure 1 object, 48 bytes ---- loop_over_scope 1 object, 40 bytes ---- parse_name_notice 1 object, 40 bytes ---- kind_template_definition 1 object, 40 bytes -37.5% was used for memory not allocated for objects: +37.4% was used for memory not allocated for objects: - 15.9% text stream storage 41840888 bytes in 263039 claims + 15.8% text stream storage 41840888 bytes in 263039 claims 3.5% dictionary storage 9265664 bytes in 16347 claims ---- sorting 1048 bytes in 3 claims 2.7% source text 7200000 bytes in 3 claims @@ -223,7 +223,7 @@ Total memory consumption was 256343K = 250 MB ---- linguistic stock array 81920 bytes in 2 claims ---- small word set array 105600 bytes in 22 claims 0.8% inter symbols storage 2277376 bytes in 13914 claims - 6.4% inter bytecode storage 16802820 bytes in 14 claims + 6.3% inter bytecode storage 16802820 bytes in 14 claims 3.3% inter links storage 8750208 bytes in 246 claims 0.5% instance-of-kind counting 1468944 bytes in 1 claim ---- lists for type-checking invocations 16000 bytes in 1 claim @@ -232,5 +232,5 @@ Total memory consumption was 256343K = 250 MB ---- emitter array storage 14368 bytes in 8 claims ---- code generation workspace for objects 9200 bytes in 9 claims -20.0% was overhead - 52690688 bytes = 51455K = 50 MB +20.2% was overhead - 53445424 bytes = 52192K = 50 MB diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index 6c9f5bdc0..ae698277d 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,13 +1,13 @@ 100.0% in inform7 run - 67.5% in compilation to Inter - 25.6% in //Phrases::Manager::compile_first_block// - 9.0% in //Phrases::Manager::compile_as_needed// + 67.1% in compilation to Inter + 25.7% in //Phrases::Manager::compile_first_block// + 8.9% in //Phrases::Manager::compile_as_needed// 6.9% in //Strings::compile_responses// - 6.2% in //World::Compile::compile// - 4.3% in //MajorNodes::pre_pass// + 6.1% in //World::Compile::compile// + 4.2% in //MajorNodes::pre_pass// 3.2% in //MajorNodes::pass_1// 2.0% in //Phrases::Manager::RulePrintingRule_routine// - 1.9% in //Phrases::Manager::rulebooks_array// + 1.8% in //Phrases::Manager::rulebooks_array// 1.0% in //VerbsAtRunTime::ConjugateVerb// 0.8% in //Phrases::Manager::traverse// 0.5% in //Phrases::Manager::compile_rulebooks// @@ -19,10 +19,10 @@ 0.1% in //PL::Parsing::Verbs::compile_all// 0.1% in //Task::make_built_in_kind_constructors// 3.4% not specifically accounted for - 30.1% in running Inter pipeline - 9.7% in inter step 2/12: link - 9.5% in step preparation - 7.1% in inter step 12/12: generate inform6 -> auto.inf + 30.5% in running Inter pipeline + 10.8% in step preparation + 9.8% in inter step 2/12: link + 6.9% in inter step 12/12: generate inform6 -> auto.inf 0.3% in inter step 9/12: make-identifiers-unique 0.1% in inter step 10/12: reconcile-verbs 0.1% in inter step 11/12: eliminate-redundant-labels @@ -31,6 +31,6 @@ 0.1% in inter step 6/12: assimilate 0.1% in inter step 7/12: resolve-external-symbols 0.1% in inter step 8/12: inspect-plugs - 2.2% not specifically accounted for - 1.9% in supervisor + 1.4% not specifically accounted for + 2.0% in supervisor 0.4% not specifically accounted for diff --git a/inform7/core-module/Chapter 11/Tree Conversions.w b/inform7/core-module/Chapter 11/Tree Conversions.w index d9081b135..c136f4559 100644 --- a/inform7/core-module/Chapter 11/Tree Conversions.w +++ b/inform7/core-module/Chapter 11/Tree Conversions.w @@ -14,15 +14,15 @@ their existence. = pcalc_prop *Propositions::Abstract::to_make_a_kind(kind *K) { - return Atoms::ISAKIND_new(Terms::new_variable(0), K); + return Calculus::Creation::is_a_kind_up(Terms::new_variable(0), K); } pcalc_prop *Propositions::Abstract::to_make_a_var(void) { - return Atoms::ISAVAR_new(Terms::new_variable(0)); + return Calculus::Creation::is_a_var_up(Terms::new_variable(0)); } pcalc_prop *Propositions::Abstract::to_make_a_const(void) { - return Atoms::ISACONST_new(Terms::new_variable(0)); + return Calculus::Creation::is_a_const_up(Terms::new_variable(0)); } pcalc_prop *Propositions::Abstract::to_create_something(kind *K, wording W) { diff --git a/inform7/core-module/Chapter 11/Type Check Propositions.w b/inform7/core-module/Chapter 11/Type Check Propositions.w index eba3b0125..e6f655531 100644 --- a/inform7/core-module/Chapter 11/Type Check Propositions.w +++ b/inform7/core-module/Chapter 11/Type Check Propositions.w @@ -86,8 +86,6 @@ int Propositions::Checker::type_check(pcalc_prop *prop, tc_problem_kit tck_s) { @; if (pl->element == NOWHERE_ATOM) @; - if (pl->element == ISAKIND_ATOM) - @; if (pl->element == HERE_ATOM) @; } @@ -290,11 +288,6 @@ would work instead. If it would, we make the change within the proposition. if (tck->log_to_I6_text) LOG("BP $o cannot be applied\n", pl); return NEVER_MATCH; -@ = - kind *actually_find = Propositions::Checker::kind_of_term(&(pl->terms[0]), &vta, tck); - if (Kinds::compatible(actually_find, K_object) == NEVER_MATCH) - internal_error("ISAKIND atom misapplied"); - @ = kind *actually_find = Propositions::Checker::kind_of_term(&(pl->terms[0]), &vta, tck); if (Kinds::compatible(actually_find, K_object) == NEVER_MATCH) { diff --git a/inform7/core-module/Chapter 12/Assert Propositions.w b/inform7/core-module/Chapter 12/Assert Propositions.w index 1702df57c..9aeffb03e 100644 --- a/inform7/core-module/Chapter 12/Assert Propositions.w +++ b/inform7/core-module/Chapter 12/Assert Propositions.w @@ -324,11 +324,18 @@ interpret no indication of a kind as meaning "object". if ((lookahead->arity == 1) && (lookahead->terms[0].variable == v)) { if (Atoms::is_CALLED(lookahead)) { NW = Atoms::CALLED_get_name(lookahead); - } else switch(lookahead->element) { - case KIND_ATOM: K = lookahead->assert_kind; break; - case ISAKIND_ATOM: is_a_kind = TRUE; K = lookahead->assert_kind; break; - case ISAVAR_ATOM: is_a_var = TRUE; break; - case ISACONST_ATOM: is_a_const = TRUE; break; + } else if (lookahead->element == KIND_ATOM) K = lookahead->assert_kind; + else if ((lookahead->element == PREDICATE_ATOM) && (lookahead->arity == 1)) { + unary_predicate *up = RETRIEVE_POINTER_unary_predicate(lookahead->predicate); + if (up->family == is_a_kind_up_family) { + is_a_kind = TRUE; K = up->assert_kind; + } + if (up->family == is_a_var_up_family) { + is_a_var = TRUE; + } + if (up->family == is_a_const_up_family) { + is_a_const = TRUE; + } } } diff --git a/inform7/core-module/Chapter 5/The Creator.w b/inform7/core-module/Chapter 5/The Creator.w index 0369d10a7..68e38cf85 100644 --- a/inform7/core-module/Chapter 5/The Creator.w +++ b/inform7/core-module/Chapter 5/The Creator.w @@ -683,6 +683,7 @@ to abbreviated forms of object names are normally allowed. else prop = Propositions::concatenate(prop, Propositions::Abstract::to_make_a_var()); Propositions::Assert::assert_true(prop, prevailing_mood); + if (NonlocalVariables::get_latest() == NULL) internal_error("failed to create"); val = Lvalues::new_actual_NONLOCAL_VARIABLE(NonlocalVariables::get_latest()); @ = diff --git a/services/calculus-module/Chapter 2/The Creation Predicates.w b/services/calculus-module/Chapter 2/The Creation Predicates.w index 76ee13c8a..abac5f334 100644 --- a/services/calculus-module/Chapter 2/The Creation Predicates.w +++ b/services/calculus-module/Chapter 2/The Creation Predicates.w @@ -7,7 +7,12 @@ exist. = (early code) up_family *calling_up_family = NULL; -up_family *creation_up_family = NULL; +up_family *is_a_var_up_family = NULL; +up_family *is_a_const_up_family = NULL; +up_family *is_a_kind_up_family = NULL; + +unary_predicate *is_a_var_up = NULL; +unary_predicate *is_a_const_up = NULL; @h Family. This is a minimal representation only: Inform adds other methods to the equality @@ -16,8 +21,19 @@ family to handle its typechecking and so on. = void Calculus::Creation::start(void) { calling_up_family = UnaryPredicateFamilies::new(); - creation_up_family = UnaryPredicateFamilies::new(); - METHOD_ADD(creation_up_family, STOCK_UPF_MTID, Calculus::Creation::stock_creation); + is_a_var_up_family = UnaryPredicateFamilies::new(); + METHOD_ADD(is_a_var_up_family, STOCK_UPF_MTID, Calculus::Creation::stock_is_a_var); + METHOD_ADD(is_a_var_up_family, LOG_UPF_MTID, Calculus::Creation::log_is_a_var); + is_a_const_up_family = UnaryPredicateFamilies::new(); + METHOD_ADD(is_a_const_up_family, STOCK_UPF_MTID, Calculus::Creation::stock_is_a_const); + METHOD_ADD(is_a_const_up_family, LOG_UPF_MTID, Calculus::Creation::log_is_a_const); + is_a_kind_up_family = UnaryPredicateFamilies::new(); + METHOD_ADD(is_a_kind_up_family, LOG_UPF_MTID, Calculus::Creation::log_is_a_kind); + #ifdef CORE_MODULE + METHOD_ADD(is_a_var_up_family, TYPECHECK_UPF_MTID, Calculus::Creation::typecheck_is_a_var); + METHOD_ADD(is_a_const_up_family, TYPECHECK_UPF_MTID, Calculus::Creation::typecheck_is_a_const); + METHOD_ADD(is_a_kind_up_family, TYPECHECK_UPF_MTID, Calculus::Creation::typecheck_is_a_kind); + #endif } @h Initial stock. @@ -25,8 +41,59 @@ This relation is hard-wired in, and it is made in a slightly special way since (alone among binary predicates) it has no distinct reversal. = -void Calculus::Creation::stock_creation(up_family *self, int n) { +void Calculus::Creation::stock_is_a_var(up_family *self, int n) { if (n == 1) { - ; // make isakind, etc., here + is_a_var_up = UnaryPredicates::blank(is_a_var_up_family); } } + +void Calculus::Creation::stock_is_a_const(up_family *self, int n) { + if (n == 1) { + is_a_const_up = UnaryPredicates::blank(is_a_const_up_family); + } +} + +pcalc_prop *Calculus::Creation::is_a_var_up(pcalc_term t) { + return Atoms::unary_PREDICATE_new(is_a_var_up, t); +} + +pcalc_prop *Calculus::Creation::is_a_const_up(pcalc_term t) { + return Atoms::unary_PREDICATE_new(is_a_const_up, t); +} + +pcalc_prop *Calculus::Creation::is_a_kind_up(pcalc_term t, kind *K) { + unary_predicate *up = UnaryPredicates::blank(is_a_kind_up_family); + up->assert_kind = K; + return Atoms::unary_PREDICATE_new(up, t); +} + +#ifdef CORE_MODULE +int Calculus::Creation::typecheck_is_a_var(up_family *self, unary_predicate *up, + pcalc_prop *prop, variable_type_assignment *vta, tc_problem_kit *tck) { + return ALWAYS_MATCH; +} +int Calculus::Creation::typecheck_is_a_const(up_family *self, unary_predicate *up, + pcalc_prop *prop, variable_type_assignment *vta, tc_problem_kit *tck) { + return ALWAYS_MATCH; +} +int Calculus::Creation::typecheck_is_a_kind(up_family *self, unary_predicate *up, + pcalc_prop *prop, variable_type_assignment *vta, tc_problem_kit *tck) { + kind *actually_find = Propositions::Checker::kind_of_term(&(prop->terms[0]), vta, tck); + if (Kinds::compatible(actually_find, K_object) == NEVER_MATCH) + internal_error("is_a_kind predicate misapplied"); + return ALWAYS_MATCH; +} +#endif + +void Calculus::Creation::log_is_a_var(up_family *self, OUTPUT_STREAM, unary_predicate *up) { + WRITE("is-a-var"); +} + +void Calculus::Creation::log_is_a_const(up_family *self, OUTPUT_STREAM, unary_predicate *up) { + WRITE("is-a-const"); +} + +void Calculus::Creation::log_is_a_kind(up_family *self, OUTPUT_STREAM, unary_predicate *up) { + WRITE("is-a-kind"); + if (up->assert_kind) WRITE("=%u", up->assert_kind); +} diff --git a/services/calculus-module/Chapter 2/Unary Predicates.w b/services/calculus-module/Chapter 2/Unary Predicates.w index e08c0a396..8feb0073f 100644 --- a/services/calculus-module/Chapter 2/Unary Predicates.w +++ b/services/calculus-module/Chapter 2/Unary Predicates.w @@ -9,16 +9,16 @@ also records its sense, i.e., positive or negative: = typedef struct unary_predicate { struct up_family *family; + struct kind *assert_kind; lcon_ti lcon; } unary_predicate; @ = -unary_predicate *UnaryPredicates::new(adjective *aph, int pos) { +unary_predicate *UnaryPredicates::blank(up_family *f) { unary_predicate *au = CREATE(unary_predicate); - au->family = adjectival_up_family; - au->lcon = Stock::to_lcon(aph->in_stock); - if (pos) au->lcon = Lcon::set_sense(au->lcon, POSITIVE_SENSE); - else au->lcon = Lcon::set_sense(au->lcon, NEGATIVE_SENSE); + au->family = f; + au->assert_kind = NULL; + au->lcon = 0; return au; } @@ -29,6 +29,14 @@ unary_predicate *UnaryPredicates::copy(unary_predicate *au_from) { return au; } +unary_predicate *UnaryPredicates::new(adjective *aph, int pos) { + unary_predicate *au = UnaryPredicates::blank(adjectival_up_family); + au->lcon = Stock::to_lcon(aph->in_stock); + if (pos) au->lcon = Lcon::set_sense(au->lcon, POSITIVE_SENSE); + else au->lcon = Lcon::set_sense(au->lcon, NEGATIVE_SENSE); + return au; +} + @ Logging: = diff --git a/services/calculus-module/Chapter 3/Atomic Propositions.w b/services/calculus-module/Chapter 3/Atomic Propositions.w index 62154ea18..ae6198468 100644 --- a/services/calculus-module/Chapter 3/Atomic Propositions.w +++ b/services/calculus-module/Chapter 3/Atomic Propositions.w @@ -34,9 +34,6 @@ of the |*_ATOM| numbers below. Those elements in turn occur in "groups". @d PREDICATES_GROUP 20 @d PREDICATE_ATOM 10 /* a regular predicate, rather than these special cases -- */ @d KIND_ATOM 11 /* a unary predicate asserting that $x$ has kind $K$ */ -@d ISAKIND_ATOM 12 /* a unary predicate asserting that $x$ is itself a kind */ -@d ISAVAR_ATOM 13 /* a unary predicate asserting that $x$ is a global variable */ -@d ISACONST_ATOM 14 /* a unary predicate asserting that $x$ is a named constant */ @d EVERYWHERE_ATOM 15 /* a unary predicate asserting omnipresence */ @d NOWHERE_ATOM 16 /* a unary predicate asserting nonpresence */ @d HERE_ATOM 17 /* a unary predicate asserting presence "here" */ @@ -201,28 +198,6 @@ pcalc_prop *Atoms::HERE_new(pcalc_term pt) { return prop; } -@ And the |ISAKIND|, |ISAVAR| and |ISACONST| creation predicates: - -= -pcalc_prop *Atoms::ISAKIND_new(pcalc_term pt, kind *K) { - pcalc_prop *prop = Atoms::new(ISAKIND_ATOM); - prop->terms[prop->arity++] = pt; - prop->assert_kind = K; - return prop; -} - -pcalc_prop *Atoms::ISAVAR_new(pcalc_term pt) { - pcalc_prop *prop = Atoms::new(ISAVAR_ATOM); - prop->terms[prop->arity++] = pt; - return prop; -} - -pcalc_prop *Atoms::ISACONST_new(pcalc_term pt) { - pcalc_prop *prop = Atoms::new(ISACONST_ATOM); - prop->terms[prop->arity++] = pt; - return prop; -} - @ |CALLED| atoms are interesting because they exist only for their side-effects: they have no effect at all on the logical status of a proposition (well, except that they should not be applied to free variables referred to nowhere else). @@ -320,15 +295,18 @@ to be able to create $U(t)$ for any term $t$, but in practice we only ever need $t=x$, that is, variable 0. = -pcalc_prop *Atoms::from_adjective(adjective *aph, int negated, pcalc_term t) { +pcalc_prop *Atoms::unary_PREDICATE_new(unary_predicate *up, pcalc_term t) { pcalc_prop *prop = Atoms::new(PREDICATE_ATOM); prop->arity = 1; prop->terms[0] = t; - prop->predicate = STORE_POINTER_unary_predicate( - UnaryPredicates::new(aph, (negated)?FALSE:TRUE)); + prop->predicate = STORE_POINTER_unary_predicate(up); return prop; } +pcalc_prop *Atoms::from_adjective(adjective *aph, int negated, pcalc_term t) { + return Atoms::unary_PREDICATE_new(UnaryPredicates::new(aph, (negated)?FALSE:TRUE), t); +} + pcalc_prop *Atoms::from_adjective_on_x(adjective *aph, int negated) { return Atoms::from_adjective(aph, negated, Terms::new_variable(0)); } @@ -442,9 +420,6 @@ void Atoms::write(text_stream *OUT, pcalc_prop *prop) { if ((Streams::I6_escapes_enabled(DL) == FALSE) && (prop->composited)) WRITE("_c"); if ((Streams::I6_escapes_enabled(DL) == FALSE) && (prop->unarticled)) WRITE("_u"); break; - case ISAKIND_ATOM: WRITE("is-a-kind"); break; - case ISAVAR_ATOM: WRITE("is-a-var"); break; - case ISACONST_ATOM: WRITE("is-a-const"); break; case EVERYWHERE_ATOM: WRITE("everywhere"); break; case NOWHERE_ATOM: WRITE("nowhere"); break; case HERE_ATOM: WRITE("here"); break; diff --git a/services/calculus-module/Chapter 3/Propositions.w b/services/calculus-module/Chapter 3/Propositions.w index 73d73ee8f..4648f346b 100644 --- a/services/calculus-module/Chapter 3/Propositions.w +++ b/services/calculus-module/Chapter 3/Propositions.w @@ -534,9 +534,12 @@ expense of typechecking the proposition: = kind *Propositions::describes_kind(pcalc_prop *prop) { pcalc_prop *p = prop; - while ((p = Propositions::prop_seek_atom(p, ISAKIND_ATOM, 1)) != NULL) { + while ((p = Propositions::prop_seek_up_family(p, is_a_kind_up_family)) != NULL) { if ((Terms::variable_underlying(&(p->terms[0])) == 0) && - (Kinds::eq(p->assert_kind, K_value))) return p->assert_kind; + (Kinds::eq(p->assert_kind, K_value))) { + unary_predicate *up = RETRIEVE_POINTER_unary_predicate(p->predicate); + return up->assert_kind; + } p = p->next; } p = prop; diff --git a/services/calculus-module/Preliminaries/What This Module Does.w b/services/calculus-module/Preliminaries/What This Module Does.w index ff6434042..27922aea8 100644 --- a/services/calculus-module/Preliminaries/What This Module Does.w +++ b/services/calculus-module/Preliminaries/What This Module Does.w @@ -179,8 +179,7 @@ calls. (*) //Atoms::from_adjective//, or (*) //Atoms::KIND_new//, or (*) //Atoms::CALLED_new//, or -(*) //Atoms::new// for the six oddball unaries, -supplying atom types |ISAKIND_ATOM|, |ISAVAR_ATOM|, |ISACONST_ATOM|, +(*) //Atoms::new// for the oddball unaries, |EVERYWHERE_ATOM|, |NOWHERE_ATOM| and |HERE_ATOM|. Binary predicate atoms are made using //Atoms::binary_PREDICATE_new//. diff --git a/services/calculus-test/Chapter 1/Declarations.w b/services/calculus-test/Chapter 1/Declarations.w index c2a3d294c..4d078b438 100644 --- a/services/calculus-test/Chapter 1/Declarations.w +++ b/services/calculus-test/Chapter 1/Declarations.w @@ -164,9 +164,9 @@ void Declarations::parse(parse_node *p) { everywhere ( ) | ==> { -, Atoms::EVERYWHERE_new(*((pcalc_term *) RP[1])) } nowhere ( ) | ==> { -, Atoms::NOWHERE_new(*((pcalc_term *) RP[1])) } here ( ) | ==> { -, Atoms::HERE_new(*((pcalc_term *) RP[1])) } - is-a-kind ( ) | ==> { -, Atoms::ISAKIND_new(*((pcalc_term *) RP[1]), NULL) } - is-a-var ( ) | ==> { -, Atoms::ISAVAR_new(*((pcalc_term *) RP[1])) } - is-a-const ( ) | ==> { -, Atoms::ISACONST_new(*((pcalc_term *) RP[1])) } + is-a-kind ( ) | ==> { -, Calculus::Creation::is_a_kind_up(*((pcalc_term *) RP[1]), NULL) } + is-a-var ( ) | ==> { -, Calculus::Creation::is_a_var_up(*((pcalc_term *) RP[1])) } + is-a-const ( ) | ==> { -, Calculus::Creation::is_a_const_up(*((pcalc_term *) RP[1])) } not< | ==> { -, Atoms::new(NEGATION_OPEN_ATOM) } not> | ==> { -, Atoms::new(NEGATION_CLOSE_ATOM) } in< | ==> { -, Atoms::new(DOMAIN_OPEN_ATOM) }