/* * Copyright 2014 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FRUIT_META_PROOF_TREES_H #define FRUIT_META_PROOF_TREES_H #include #include #include #include #include namespace fruit { namespace impl { namespace meta { // Given a set of formulas Hps=Set and a formula Th, Pair represents the // following proof tree: // // Hp1 ... Hp(n) // ------------- // Th // // Hp1, ... Hp(n) must be distinct. // Formulas are atomic, any type can be used as formula (except None). // // A proof forest is a map (i.e. a Set of Pair(s)) from each Th to the corresponding set of Hps. // Note that a proof forest doesn't need to have any additional property (for example, a proof tree // might contain the thesis as hypotheses, or there might be a longer loop e.g A=>B, B=>A. using EmptyProofForest = EmptySet; #if !FRUIT_NO_LOOP_CHECK using ProofForestFindHps = GraphFindNeighbors; // ProofForestFindLoop(F) returns a loop in the given forest as a Vector such that: // IsInSet(Th1, ProofForestFindHps(Th2)), IsInSet(Th2, ProofForestFindHps(Th3)), ..., // IsInSet(Th{k-1}, ProofForestFindHps(Thk)), IsInSet(Thk, ProofForestFindHps(Th1)) // if there is no such loop, returns None. using ProofForestFindLoop = GraphFindLoop; #else // FRUIT_NO_LOOP_CHECK struct ProofForestFindLoop { template struct apply { using type = None; }; }; struct AddProofTreeToForest { template struct apply { using type = Vector<>; }; }; struct AddProofTreeSetToForest { template struct apply { using type = Vector<>; }; }; #endif // FRUIT_NO_LOOP_CHECK } // namespace meta } // namespace impl } // namespace fruit #endif // FRUIT_META_PROOF_TREES_H