Skip to content

Commit

Permalink
Start to add ground truth "sanity checks"
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-eschwartz committed Nov 17, 2022
1 parent 3212faa commit 07b65dd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
25 changes: 25 additions & 0 deletions share/prolog/oorules/insanity.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
% Sanity checking rules
% ============================================================================================

:- table haveGround/0 as opaque.
haveGround :- groundTruth(_, _, _, _, _, _, _, _, _), !.

% If we have ground truth, did we merge two different classes together?
:- table insanityGroundBadMerge/1 as incremental.
insanityGroundBadMerge(Out) :-

find(M1, C),
groundTruth(M1, C1, _, _, _, _, _, _, _),
find(M2, C),
iso_dif(M1, M2),
groundTruth(M2, C2, _, _, _, _, _, _, _),
iso_dif(C1, C2),

Out = (
logwarnln('Consistency checks failed.~n~Q and ~Q are on the same class, but ground truth says they are on ~Q and ~Q.', [M1, M2, C1, C2])
).


% If we say we have no base classes, we have no base classes :-)
:- table insanityNoBaseConsistency/1 as incremental.
insanityNoBaseConsistency(Out) :-
Expand Down Expand Up @@ -330,6 +349,7 @@

:- table sanityChecks/1 as incremental.
sanityChecks(Out) :-
groundSanityChecks(Out);
insanityNoBaseConsistency(Out);
insanityEmbeddedAndNot(Out);
insanityConstructorAndNotConstructor(Out);
Expand All @@ -348,6 +368,11 @@
insanityContradictoryNOTConstructor(Out);
insanityTwoRealDestructorsOnClass(Out).

groundSanityChecks(Out) :-
haveGround,

insanityGroundBadMerge(Out).

sanityChecks :-
sanityChecks(Out)
->
Expand Down
15 changes: 11 additions & 4 deletions share/prolog/oorules/ooprolog.pl
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
generate_results(Opts) :-
check_option(facts(Facts), Opts),
option(results(Results), Opts), !,
load_ground(Opts),
( current_prolog_flag(break_level, _) % interactive session
-> psolve_no_halt(Facts)
; setup_call_cleanup(
Expand Down Expand Up @@ -269,17 +270,23 @@
run_with_backtrace(exportJSONTo(JsonFile))
; true.

%% If there is a ground option, validate results
validate_results(Opts) :-
load_ground(Opts) :-
check_option(ground(Ground), Opts) ->
setup_call_cleanup(
open(Ground, read, Stream),
run_with_backtrace(
(loadPredicates(stream(Stream)),
validateResults)),
loadPredicates(stream(Stream))
),
close(Stream))
; true.

%% If there is a ground option, validate results
validate_results(Opts) :-
check_option(ground(_Ground), Opts) ->
(load_ground(Opts),
validateResults)
; true.

/* Local Variables: */
/* mode: prolog */
/* fill-column: 95 */
Expand Down

0 comments on commit 07b65dd

Please sign in to comment.