The history of Scots law traces the development of Scots law from its early beginnings as a number of different custom systems among Scotland's early cultures to its modern role as one of the three legal jurisdictions of the United Kingdom. The various historic sources of Scots law, including custom, feudal law, canon law, Roman law and English law have created a hybrid or mixed legal system, which shares elements with English law and Northern Irish law but also has its own unique legal institutions and sources. Origins The nature of Scots law before the 12th century is largely speculative but most likely was a folk-right system applying a specific customary legal tradition to a certain culture inhabiting a certain corresponding area at the time, e.g. Brehon law for the Gaels (Scoti and men of Galloway and Ayrshire), Welsh law for lowland Britons of Yr Hen Ogledd, Udal law for the Norse of Caithness and the islands, and Anglo-Saxon custom in Lothian and Borders. The earliest preserved Scottish law code is the Leges inter Brettos et Scottos, promulgated under David I (r. 1124 – 1153) and regulating Welsh and Gaelic custom. The Leges Quatuor Burgorum (‘Laws of the Four Burghs’) was promulgated sometime between 1135–57 and regulated Lothian law. It is difficult to say with any certainty to what degree contemporary Scots law still incorporates these customary sources. There is evidence to suggest that as late as the 17th century marriage laws in the Highlands and Islands still reflected Gaelic custom, contrary to Catholic religious principles. The formation of the Kingdom of Scotland and its subjugation of the surrounding cultures, completed by the Battle of Carham, established what is approximately the boundaries of contemporary mainland Scotland. The Outer Hebrides were added after the Battle of Largs in 1263 and the Northern Isles were acquired in 1469, completing what is today the legal jurisdiction of Scotland. Feudalism In the 12th century King David I began the gradual introduction of feudalism in Scotland and established feudal land tenure over many parts of the south and east, which eventually spread northward. As feudalism began to develop in Scotland a number of separate court systems developed. Sheriffs were appointed by the King in the south and over time spread north. Their scope gradually developed and they were fully established across mainland Scotland by 1300. The sheriffs were originally appointed by the King as royal