PREFIX n3: <https://www.w3.org/ns/n3#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
PREFIX : <http://example.org/test#>
PREFIX r: <http://www.w3.org/2000/10/swap/reason#>

[] a r:Proof, r:Conjunction;
  r:component <#lemma1>;
  r:gives {
    :task1 a :AllTasksCompleted.
  }.

<#lemma1> a r:Inference;
  r:gives {
    :task1 a :AllTasksCompleted.
  };
  r:evidence (
    <#lemma2>
    <#lemma3>
  );
  r:rule <#lemma4>.

<#lemma2> a r:Extraction;
  r:gives {
    :task1 a :CompositeTask.
  };
  r:because [ a r:Parsing; r:source <http://josd.github.io/eye/reasoning/n3c/tasks.n3>].

<#lemma3> a r:Inference;
  r:gives {
    ({:task1 :subTask _:sk_0} {_:sk_0 a :Completed}) n3:forAllIn <http://josd.github.io/eye/reasoning/n3c/subtasks.n3>.
  };
  r:evidence (
    [ a r:Fact; r:gives {<http://josd.github.io/eye/reasoning/n3c/subtasks.n3> log:semantics {:task1 :subTask :subtask1.
     :subtask1 a :Completed.
     :task1 :subTask :subtask2.
     :subtask2 a :Completed.
     :task1 :subTask :subtask3.
     :subtask3 a :Completed.
     :task2 :subTask :subtask4.
     :subtask4 a :Completed.
     :task2 :subTask :subtask5}}]
    [ a r:Fact; r:gives {("forall" {{:task1 :subTask :subtask1.
      :subtask1 a :Completed.
      :task1 :subTask :subtask2.
      :subtask2 a :Completed.
      :task1 :subTask :subtask3.
      :subtask3 a :Completed.
      :task2 :subTask :subtask4.
      :subtask4 a :Completed.
      :task2 :subTask :subtask5} log:includes {:task1 :subTask ?V0}} {{:task1 :subTask :subtask1.
      :subtask1 a :Completed.
      :task1 :subTask :subtask2.
      :subtask2 a :Completed.
      :task1 :subTask :subtask3.
      :subtask3 a :Completed.
      :task2 :subTask :subtask4.
      :subtask4 a :Completed.
      :task2 :subTask :subtask5} log:includes {?V0 a :Completed}}) e:derive true}]
  );
  r:rule <#lemma5>.

<#lemma4> a r:Extraction;
  r:gives {
    {?x_0_1 a :CompositeTask.
     ({?x_0_1 :subTask ?x_1_1} {?x_1_1 a :Completed}) n3:forAllIn <http://josd.github.io/eye/reasoning/n3c/subtasks.n3>} => {?x_0_1 a :AllTasksCompleted}.
  };
  r:because [ a r:Parsing; r:source <http://josd.github.io/eye/reasoning/n3c/forAllIn_query.n3>].

<#lemma5> a r:Extraction;
  r:gives {
    {(?x_2_2 ?x_3_2) n3:forAllIn ?x_0_2} <= {?x_0_2 log:semantics ?x_1_2.
     ("forall" {?x_1_2 log:includes ?x_2_2} {?x_1_2 log:includes ?x_3_2}) e:derive true}.
  };
  r:because [ a r:Parsing; r:source <http://josd.github.io/eye/reasoning/n3c/components.n3>].

